note 106399 deleted from function.array-combine by danbrown
| From: | danbrown@php.net | Date: | Tue, 15 Nov 2011 16:52:45 +0000 |
| Subject: | note 106399 deleted from function.array-combine by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184512@lists.php.net to get a copy of this message | ||
Note Submitter: WGR Studio
----
Alternative "array_combine" function
<?php
function helper_array_combine(array $array_1, array $array_2, $use_k = null) {
$r = array(); // return
foreach ($array_1 as $k => $v) {
// use key or value of first array
((bool)$use_k and $key = $k) or $key = $v;
// only if is set
isset($array_2[$key]) and $r[$key] = $array_2[$key];
}
unset($k, $v, $key);
return $r;
}
// -EOF-