note 102659 deleted from function.key by danbrown
| From: | danbrown@php.net | Date: | Sun, 27 Feb 2011 16:23:59 +0000 |
| Subject: | note 102659 deleted from function.key by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177376@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
while ($fruit_name = current($array)) {
if ($fruit_name == 'apple') {
echo key($array).'<br />';
}
next($array);
}
when submitting a form that has optional fields (input type=text left blank) the code above will
fail on the comparison of "" stored in the variable.
while ($key = key($array)) {
$fruit_name = current($array);
if ($fruit_name == 'apple') {
echo $key.'<br />';
}
next($array);
}