php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #9441 New feature for foreach control structure
Submitted: 2001-02-25 09:02 UTC Modified: 2009-05-04 15:08 UTC
From: php at leon dot brooks dot fdns dot net Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.4pl1 OS: (all, using) Linux 2.2.18
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at leon dot brooks dot fdns dot net
New email:
PHP Version: OS:

 

 [2001-02-25 09:02 UTC] php at leon dot brooks dot fdns dot net
Would find it convenient to do this:

$filehandle=fopen("file","r");
foreach ($filehandle as $line) {
    # process line (line ends stripped off)
}
fclose ($filehandle);

...and even this...

$filehandle=fopen("file","r");
foreach ($filehandle as $line[]) {
    # $line[0] = whole line sans ends
    # $line[1] = first word (exploded out gawk-like)
    # $line[2] = second word, etc
}
fclose ($filehandle);

...just a thought.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-02 09:21 UTC] parham_m_s at hotmail dot com
i recently converted from perl to php and this was the first thing i realized.  The foreach construct should be implemented into files because it's just eyepleasing (and easier) for some people.  The same idea should also be applied to opendir (or even dumping an entire directory tree into an array).
 [2009-05-04 15:08 UTC] pajoye@php.net
Use file()
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 03:05:45 2022 UTC