php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31123 Change of return values
Submitted: 2004-12-16 14:35 UTC Modified: 2004-12-16 14:37 UTC
From: bate@php.net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.10 OS: FreeBSD
Private report: No CVE-ID: None
 [2004-12-16 14:35 UTC] bate@php.net
Description:
------------
foreach mechanism changed. foreach returns now the array not the key. This changed from 4.3.9 to 4.3.10


5.0.x retuns too as $key the sub arrays

Reproduce code:
---------------
<pre>
<?php
$demo_array = array('one', 'two', 'three');

print_r(array_keys($demo_array));
echo "\n\n";
foreach(array_keys($demo_array) as $key)
{
    echo $key."<br>";
}

?>

Expected result:
----------------
Array
(
    [0] => 0
    [1] => 1
    [2] => 2
)


0
1
2

Actual result:
--------------
Array
(
    [0] => 0
    [1] => 1
    [2] => 2
)


Array
Array
Array

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-16 14:37 UTC] derick@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. 

Thank you for your interest in PHP.

Get rid/upgrade your Zend extensions, no bug here.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 28 08:00:03 2025 UTC