Combining Two Arrays Into One

Description: A quick bit of code for combining two arrays into one.

<?PHP
 
FUNCTION array_combine($arr1, $arr2) {
     $out = ARRAY();
 
     $arr1 = ARRAY_VALUES($arr1);
     $arr2 = ARRAY_VALUES($arr2);
 
     FOREACH($arr1 AS $key1 => $value1) {
     $out[(string)$value1] = $arr2[$key1];
     }
 
     RETURN $out;
}
 
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.