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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: web at developer dot bg
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 11:01:31 2024 UTC