note 17092 added to function.array-keys
| From: | massimo at sandlab dot org | Date: | Mon, 26 Nov 2001 10:25:34 +0000 |
| Subject: | note 17092 added to function.array-keys | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-21275@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;
}
--
http://www.php.net/manual/en/function.array-keys.php
http://master.php.net/manage/user-notes.php?action=edit+17092
http://master.php.net/manage/user-notes.php?action=delete+17092
http://master.php.net/manage/user-notes.php?action=reject+17092