php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47264 currtent($myArray) not returning correct item
Submitted: 2009-02-01 23:04 UTC Modified: 2009-02-02 00:51 UTC
From: george at shoutbomb dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.8 OS: windows 2003
Private report: No CVE-ID: None
 [2009-02-01 23:04 UTC] george at shoutbomb dot com
Description:
------------
When requesting the 'current' pointer in an array it always returns the 'first' item.

Reproduce code:
---------------
$search_array = array('first' => 1, 'second' => 4,'third' => 51, 'fourth' => 54,'fifth' => 15);
if (array_key_exists('fourth', $search_array)) {
    echo current($search_array);
}

Expected result:
----------------
Expecting the 'fourth' item.

Actual result:
--------------
Always returns the 'first' item.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-02 00:51 UTC] colder@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

That's because you don't move the array pointer. See next().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 07:01:32 2024 UTC