php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51645 array_walk for DOMNodeList
Submitted: 2010-04-23 12:17 UTC Modified: 2010-04-27 17:33 UTC
From: emm980 at windowslive dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.2 OS: Win 7
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: emm980 at windowslive dot com
New email:
PHP Version: OS:

 

 [2010-04-23 12:17 UTC] emm980 at windowslive dot com
Description:
------------
An updated array_walk for DOMNodeList objects.

Since these objects can be used in a foreach loop just like ordinary arrays it would be nice and a way to improve performance if it were to be possible to use then with a walker function. On the windows platform at least, array_walk is significantly faster than foreach, especially in situation where the arrays have thousands of elements or more, which I suppose is its intended use.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-23 12:45 UTC] rrichards@php.net
-Status: Open +Status: Bogus
 [2010-04-23 12:45 UTC] rrichards@php.net
Just because its iterable does not mean its an array. There are other ways to 
access it than foreach.
 [2010-04-27 16:41 UTC] emm980 at windowslive dot com
"foreach: ... This simply gives an easy way to iterate over arrays. foreach works only on arrays, and will issue an error when you try to use it on a variable with a different data type..." PHP Manual

That doesn't mean it's not a good idea to make it work.

Other ways of iterating through a node list are the usual loops. But as I've clearly stated, they are slow, when array_walk is faster. That's the whole point of my request.
 [2010-04-27 17:33 UTC] johannes@php.net
See iterator_apply().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 19:01:33 2024 UTC