note 74120 added to function.array-combine
| From: | Wiebe at osu1 dot php dot net | Date: | Mon, 26 Mar 2007 09:05:43 +0000 |
| Subject: | note 74120 added to function.array-combine | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124806@lists.php.net to get a copy of this message | ||
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'
?>
----
Server IP: 83.137.20.120
Probable Submitter: 83.116.35.81
----
Manual Page -- http://www.php.net/manual/en/function.array-combine.php
Edit -- https://master.php.net/note/edit/74120
Del: integrated -- https://master.php.net/note/delete/74120/integrated
Del: useless -- https://master.php.net/note/delete/74120/useless
Del: bad code -- https://master.php.net/note/delete/74120/bad+code
Del: spam -- https://master.php.net/note/delete/74120/spam
Del: non-english -- https://master.php.net/note/delete/74120/non-english
Del: in docs -- https://master.php.net/note/delete/74120/in+docs
Del: other reasons-- https://master.php.net/note/delete/74120
Reject -- https://master.php.net/note/reject/74120
Search -- https://master.php.net/manage/user-notes.php