DomQuery::walk();

Apply a user-defined callback function to every element within a result set. This can be an external function or a method of a class. All arguments passed through this method will be passed into the callback function. The first argument passed through the callback will always be the current result's context. The context argument is an array that contains the current document, current element and complete result set of the last xpath query all by reference. The first parameter passed to the callback will be an array containing the following values:

 array
 (
     'results'  => &$this->Results,       // The current result set of the last XPath expression
     'element'  => $Result,               // The currently iterated element
     'position' => $this->Results->key(), // The currently itereted element's position within the result set
     'context'  => &$this                 // Instance of DomQuery
 )

All of the following examples are acceptable.

 $DomQuery = new DomQuery;
 $DomQuery->load($xml);
 $DomQuery->walk('my_function', 'arg_one', 'arg_two');
 $DomQuery->walk(array('my_static_class', 'my_static_method'), 'arg_one', 'arg_two');
 $DomQuery->walk(array($Instance, 'my_method'), 'arg_one', 'arg_two');

Definition:

public function walk($callback)

Parameters:

Name Type Description
$callback String | Array The callback method or function to apply result elements.

Recent Discussions

No discussions yet!