Note Submitter: dkrysiak at o2 dot pl
----
// note: my previous post have one small error in call to array_key_exists() - posting again - please remove this comment and that note :-)
<?php
/* 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 Keys/indexes of elements to choose
* @return Array Array with elements being references to the elements od original array with chosen indexes.
*/
function &array_select($arr, $keys)
{
$res = array();
foreach ($keys as $key) {
if (array_key_exists($key, $arr)) {
$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)
*/
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.