Arrays
|
|
|
|
<?php /*
Name: array_merge_assoc
Author: Markus Diersbock
Details: Takes two related indexed arrays and
combines them into one associative array.
Notes: If $keyarray is NOT greater or equal to $valuearray
the function will error unless the optional $force=TRUE.
Revisions: 2003/12/13 - Created
2004/01/14 - Added code for unequal arrays
*/
function array_merge_assoc($keyarray, $valuearray, $force=FALSE){
$i=0;
if ((count($keyarray) >= count($valuearray)) || $force==TRUE) {
foreach($keyarray as $element){
$aryreturn[$element]=$valuearray[$i++];
}
} else {
return 'Arrays are not of equal size';
}
return $aryreturn;
}
?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|