php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24754 each() seems to return BOOL instead of ARRAY
Submitted: 2003-07-22 12:20 UTC Modified: 2003-07-22 12:25 UTC
From: web at developer dot bg Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.2 OS: Windows2000 Adv Server
Private report: No CVE-ID: None
 [2003-07-22 12:20 UTC] web at developer dot bg
Description:
------------
Under certain circumstances a variable storing the result of each() contains the boolean TRUE instead of the array or FALSE that is normaly expected.

The code will give you an idea what exactly is the problem.

Reproduce code:
---------------
$arr = array('apple', 'banana', 'strawberry', 'pineapple', 'orange');
$i = 0;
while($fruit=each($arr) || $i>=3)
 {
 echo $fruit[value].'<br>';
 $i++;
 }

Expected result:
----------------
apple
banana
strawberry

Actual result:
--------------
1
1
1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-22 12:25 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Read the manual about operator precedence again.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 21:01:32 2025 UTC