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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 13:01:27 2025 UTC