Skip to content

Commit 7175a75

Browse files
committed
XPath Key Array added to readme.
1 parent f0a4417 commit 7175a75

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,25 @@ You can unset nested key.
112112
var_dump($array['foo']); // => array(0) {}
113113
```
114114

115-
After nested manipulations you might want to get back the **real array**. This can be done by calling `$array->toArray()`.
115+
After nested manipulations you might want to get back the **real array**. This can be done by calling `$array->toArray()`.
116+
117+
## XPath Key Array
118+
119+
**This is not a real xpath!** This class instead of array-like key users string of keys delimited with `/`.
120+
121+
```php
122+
$array = new XPathKeyArray([
123+
'foo' => [
124+
'bar' => 'baz'
125+
]
126+
]);
127+
128+
var_dump($array['foo/bar']); // => string(3) "baz"
129+
```
130+
131+
This one was inspired by [an old article](http://codeaid.net/php/get-values-of-multi-dimensional-arrays-using-xpath-notation).
132+
133+
Compared to `CompositeKeyArray`, `XPathKeyArray` has some limitations:
134+
135+
1. You cannot use keys with `/` in them.
136+
2. You cannot use `null` as key.

0 commit comments

Comments
 (0)