Arrays
|
|
|
|
<?php function array_expand($base = 0, $extra = 0) {
// Take two one-dimensional array, step through the first looking for
// each element of the second. If any of the elements in the second
// array are not in the first, append them. Kind of an extended version
// of PHP4's array_merge() function
if (!is_array($base))
return false;
$ext_arr = (is_array($extra)) ? $extra : array($extra);
for ($i = 0; $i < sizeof($ext_arr); $i++) {
if (!in_array($ext_arr[$i], $base))
$base[] = $ext_arr[$i];
}
return $base;
} ?>
|
|
|
Usage Example
|
$new_array = $array1 + $array2;
|
|
|
Rate This Script
|
|
|
|