Method Summary

Flattens an array for sorting

Maps the given value as an object. If $value is an object,
it returns $value. Otherwise it maps $value as an object of
type $class, and if primary assign name $key on first array.
If $value is not empty, it will be used to set properties of
returned object (recursively). If $key is numeric will maintain array
structure

Allows the application of a callback method to elements of an
array extracted by a Set::extract() compatible path.

Checks if a particular path is set in an array

Gets a value from an array or object that is contained in a given path using an array path syntax, i.e.:
"{n}.Person.{[a-z]+}" - Where "{n}" represents a numeric key, "Person" represents a string literal,
and "{[a-z]+}" (i.e. any string literal enclosed in brackets besides {n} and {s}) is interpreted as
a regular expression.

Creates an associative array using a $path1 as the path to build its keys, and optionally
$path2 as path to get the values. If $path2 is not specified, all values will be initialized
to null (useful for Set::merge). You can optionally group the values by what is obtained when
following the path specified in $groupPath.

Maps the contents of the Set object to an object hierarchy.
Maintains numeric keys as arrays of objects

This function can be used to see if a single item or a given xpath match certain conditions.

This function can be thought of as a hybrid between PHP's array_merge and array_merge_recursive. The difference
to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge)
but does not do if for keys containing strings (unlike array_merge_recursive).

Parameters

Returns

Maps the given value as an object. If $value is an object,
it returns $value. Otherwise it maps $value as an object of
type $class, and if primary assign name $key on first array.
If $value is not empty, it will be used to set properties of
returned object (recursively). If $key is numeric will maintain array
structure

Link

Gets a value from an array or object that is contained in a given path using an array path syntax, i.e.:
"{n}.Person.{[a-z]+}" - Where "{n}" represents a numeric key, "Person" represents a string literal,
and "{[a-z]+}" (i.e. any string literal enclosed in brackets besides {n} and {s}) is interpreted as
a regular expression.

Parameters

array
$data

Array from where to extract

string|array
$pathoptionalnull

As an array, or as a dot-separated string.

Returns

mixedAn array of matched items or the content of a single selected item or null in any of these cases: $path or $data are null, no items found.

Creates an associative array using a $path1 as the path to build its keys, and optionally
$path2 as path to get the values. If $path2 is not specified, all values will be initialized
to null (useful for Set::merge). You can optionally group the values by what is obtained when
following the path specified in $groupPath.

Parameters

Returns

Implements partial support for XPath 2.0. If $path does not contain a '/' the call
is delegated to Set::classicExtract(). Also the $path and $data arguments are
reversible.

Currently implemented selectors:

/User/id (similar to the classic {n}.User.id)

/User[2]/name (selects the name of the second User)

/User[id>2] (selects all Users with an id > 2)

/User[id>2][<5] (selects all Users with an id > 2 but < 5)

/Post/Comment[author_name=john]/../name (Selects the name of all Posts that have at least one Comment written by john)

/Posts[name] (Selects all Posts that have a 'name' key)

/Comment/.[1] (Selects the contents of the first comment)

/Comment/.[:last] (Selects the last comment)

/Comment/.[:first] (Selects the first comment)

/Comment[text=/cakephp/i] (Selects the all comments that have a text matching the regex /cakephp/i)

/Comment/@* (Selects the all key names of all comments)

Other limitations:

Only absolute paths starting with a single '/' are supported right now

Warning: Even so it has plenty of unit tests the XPath support has not gone through a lot of
real-world testing. Please report Bugs as you find them. Suggestions for additional features to
implement are also very welcome!

Parameters

string
$path

An absolute XPath 2.0 path

array
$dataoptionalnull

An array of data to extract from

array
$optionsoptionalarray()

Currently only supports 'flatten' which can be disabled for higher XPath-ness

Returns

mixedAn array of matched items or the content of a single selected item or null in any of these cases: $path or $data are null, no items found.

Returns

Link

This function can be thought of as a hybrid between PHP's array_merge and array_merge_recursive. The difference
to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge)
but does not do if for keys containing strings (unlike array_merge_recursive).

Since this method emulates array_merge, it will re-order numeric keys. When combined with out of
order numeric keys containing arrays, results can be lossy.

Note: This function will work with an unlimited amount of arguments and typecasts non-array
parameters into arrays.

Link

Parameters

mixed
$data

Data

array
$optionsoptionalarray()

Options are:
children - the key name to use in the resultset for children
idPath - the path to a key that identifies each entry
parentPath - the path to a key that identifies the parent of each entry
root - the id of the desired top-most result