Skip to content

Commit

Permalink
Merge pull request #22 from dmeybohm/better-doc
Browse files Browse the repository at this point in the history
Improve doc.
  • Loading branch information
dmeybohm authored Jul 28, 2023
2 parents c280e54 + 49d02fa commit a971256
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,35 @@ composer require best/dot-notation

This package has a single class with static methods, `\Best\DotNotation`.

These methods all take an array as their first argument, and most then a "key path" as their
There are two main groups of methods: those that operate recursively
across an entire array, and those that get/set values from such arrays.

### Recursive methods

For the recursive methods, you can use `expand` and `compact` methods to convert
the dots from the expanded form and the compact form, and these operations are
inverses of each other:

```php
use Best\DotNotation;

$array = DotNotation::compact(array(
'my' => array(
'dotted' ==> array(
'key' => 'value'
)
)
));
// returns the dotted array:
array('my.dotted.key' => 'value');

// convert back to the other form:
$original = DotNotation::expand(['my.dotted.key' => 'value']);
```

### Get/set values

For the other methods, pass an array as their first argument, and most then a "key path" as their
second argument, that determines which keys on the array to operate on.

The key path can include dots to indicate subkeys of arrays to access.
Expand Down

0 comments on commit a971256

Please sign in to comment.