note 102659 deleted from function.key by danbrown
[email protected] Sun, 27 Feb 2011 08:23:59 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
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);
}