php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #15488 Bug in foreach example?
Submitted: 2002-02-10 10:47 UTC Modified: 2002-02-10 10:49 UTC
From: saajan at saajmin dot f9 dot co dot uk Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.1.1 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: saajan at saajmin dot f9 dot co dot uk
New email:
PHP Version: OS:

 

 [2002-02-10 10:47 UTC] saajan at saajmin dot f9 dot co dot uk
I was looking through a php manual that I downloaded yesterday (php_manual_en.pdf.zip) and noticed what looks like an error on page 149 (PDF page 216).  Right at the bottom of the page, there is a foreach() usage example.  Example 2 is as follows:

/* foreach example 2: value (with key printed for illustration) */
$a = array (1, 2, 3, 17);
$i = 0; /* for illustrative purposes only */
foreach($a as $v) {
print "\$a[$i] => $v.\n";
}

But $i will always be 0, as it is never modified in the loop!  I found the same error in the online manual at http://www.php.net/manual/en/control-structures.foreach.php

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-10 10:49 UTC] derick@php.net
This bug has been fixed in CVS.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 15:01:34 2025 UTC