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
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: 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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC