Home >> Snippet List >> Snippet

Name
Combining three arrays into one
Description
This code combines three arrays into one multidimensional array
PHP Snippet
<?PHP
 
FUNCTION double_array_combine($arr1, $arr2, $arr3) {
     $out = ARRAY();
 
     $arr1 = ARRAY_VALUES($arr1);
     $arr2 = ARRAY_VALUES($arr2);
     $arr3 = ARRAY_VALUES($arr3);
 
     FOREACH($arr1 AS $key1 => $value1) {
     $out[(string)$value1][0] = $arr2[$key1];
     $out[(string)$value1][1] = $arr3[$key1];
     }
 
     RETURN $out;
}
 
?>