note 17092 deleted from function.array-keys by jimw
| From: | jimw@php.net | Date: | Fri, 14 Dec 2001 21:17:48 +0000 |
| Subject: | note 17092 deleted from function.array-keys by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-22824@lists.php.net to get a copy of this message | ||
I think the compatibility function for php3 has a problem, infact as you can see the return is
inside the while, this way it only return the first key and not the others. To avoid this problem
you have to put the return outside the while loop.
Working Version :
function array_keys ($arr, $term="") {
$t = array();
while (list($k,$v) = each($arr)) {
if ($term && $v != $term) {
continue;
$t[] = $k;
}
}
return $t;
}