note 72821 deleted from ref.array by tularis
| From: | tularis@php.net | Date: | Fri, 02 Feb 2007 13:08:55 +0000 |
| Subject: | note 72821 deleted from ref.array by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-122540@lists.php.net to get a copy of this message | ||
Note Submitter: dkrysiak at o2 dot pl
----
/* Another version of subArr() function by simone dot carletti at unimc dot it: */
//{{{ array_select()
/**
* Choose array element with given keys
* @param Array $arr
* @param Array $keys Selected keys/indexes
* @return Array Array with elements being references to the elements od original array with chosen
indexes.
* @author Dawid Krysiak <dawid at o2 dot pl>
*/
function &array_select($arr, $keys)
{
$res = array();
foreach ($keys as $key) {
if (array_key_exists($key)) {
$res[$key] =& $arr[$key];
}
}
return $res;
} // end: array_select() }}}
/*
In my opinion it should be faster than subArr().
Another difference from subArr() is that elements of returned array are references to the same
variables as elements of original array (this can be easily changed)
*/
?>