note 74120 deleted from function.array-combine by bjori

From: Date: Thu, 21 Feb 2008 20:25:03 +0000
Subject: note 74120 deleted from function.array-combine by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-136366@lists.php.net to get a copy of this message
Note Submitter: Wiebe ---- When you have not the use off PHP 5. The workaround off 'Ivo van Sandick' can be much shorter. I use my function: <? // combine $arr with $arr_to_key where $arr_to_key becomes key of $arr. function array_comb($arr, $arr_to_key){ $i = 0; foreach($arr_to_key AS $value){ $arr_combined[$value] = $arr[$i]; $i++; } RETURN $arr_combined; } //example. $arr_1[0] = 'apple'; $arr_1[1] = 'banana'; $arr_2[0] = 'green'; $arr_2[1] = 'yellow'; $arr_comb = array_comb($arr_1, $arr_2); //$arr_comb['green'] = 'apple' //$arr_comb['yellow'] = 'banana' ?>

« previous php.notes (#136366) next »