note 102659 added to function.key

[email protected] Sun, 27 Feb 2011 02:05:47 -0800
Newsgroups php.notes
Message-ID <[email protected]>
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);
}
----
Server IP: 64.71.164.2
Probable Submitter: 68.236.207.3
----
Manual Page -- http://www.php.net/manual/en/function.key.php
Edit        -- https://master.php.net/note/edit/102659
Del: integrated  -- https://master.php.net/note/delete/102659/integrated
Del: useless     -- https://master.php.net/note/delete/102659/useless
Del: bad code    -- https://master.php.net/note/delete/102659/bad+code
Del: spam        -- https://master.php.net/note/delete/102659/spam
Del: non-english -- https://master.php.net/note/delete/102659/non-english
Del: in docs     -- https://master.php.net/note/delete/102659/in+docs
Del: other reasons-- https://master.php.net/note/delete/102659
Reject      -- https://master.php.net/note/reject/102659
Search      -- https://master.php.net/manage/user-notes.php