3 |
// $Id$ |
// $Id$ |
4 |
// ----------------------------------------------------------------------------- |
// ----------------------------------------------------------------------------- |
5 |
// $Log$ |
// $Log$ |
6 |
|
// Revision 1.5 2003/02/04 08:22:34 joko |
7 |
|
// + function is_hash |
8 |
|
// + function array_join_merge |
9 |
|
// |
10 |
// Revision 1.4 2002/12/22 13:29:54 jonen |
// Revision 1.4 2002/12/22 13:29:54 jonen |
11 |
// + added number format helper functions: |
// + added number format helper functions: |
12 |
// + number_format_locale() |
// + number_format_locale() |
189 |
} |
} |
190 |
} |
} |
191 |
|
|
192 |
|
|
193 |
|
// from: php.net - http://www.php.net/manual/en/function.array-merge-recursive.php |
194 |
|
function is_hash( $var ) { |
195 |
|
if( is_array( $var ) ) { |
196 |
|
$keys = array_keys( $var ); |
197 |
|
$all_num = true; |
198 |
|
for( $i=0; $i<count($keys); $i++ ) |
199 |
|
if( is_string($keys[$i] ) ) return true; |
200 |
|
} |
201 |
|
return false; |
202 |
|
} |
203 |
|
|
204 |
|
// from: php.net - http://www.php.net/manual/en/function.array-merge-recursive.php |
205 |
|
function array_join_merge( $arr1, $arr2 ) { |
206 |
|
if( is_array( $arr1 ) and is_array( $arr2 ) ) { |
207 |
|
// the same -> merge |
208 |
|
$new_array = array(); |
209 |
|
|
210 |
|
if( is_hash( $arr1 ) and is_hash( $arr2 ) ) { |
211 |
|
// hashes -> merge based on keys |
212 |
|
$keys = array_merge( array_keys( $arr1 ), array_keys( $arr2 ) ); |
213 |
|
foreach( $keys as $key ) { |
214 |
|
$new_array[$key] = array_join_merge( $arr1[$key], $arr2[$key] ); |
215 |
|
} |
216 |
|
} else { |
217 |
|
// two real arrays -> merge |
218 |
|
$new_array = |
219 |
|
array_reverse(array_unique(array_reverse(array_merge($arr1,$arr2)))); |
220 |
|
} |
221 |
|
|
222 |
|
return $new_array; |
223 |
|
} else { |
224 |
|
// not the same ... take new one if defined, else the old one stays |
225 |
|
return $arr2 ? $arr2 : $arr1; |
226 |
|
} |
227 |
|
} |
228 |
|
|
229 |
?> |
?> |