https://github.com/p810/dot
A utility for traversing arrays using dot notation
https://github.com/p810/dot
Last synced: about 1 year ago
JSON representation
A utility for traversing arrays using dot notation
- Host: GitHub
- URL: https://github.com/p810/dot
- Owner: p810
- License: mit
- Created: 2016-02-10T21:06:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-08-08T20:20:16.000Z (almost 7 years ago)
- Last Synced: 2025-03-25T16:06:02.734Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Dot
> A utility for traversing arrays using dot notation
## Installation
```
$ composer require p810/dot
```
## Example usage
```php
[
'bar' => 'Hello world!'
]
]);
#=> string(12) "Hello world!"
```
## API
#### `p810\Dot\find(string $needle, array $haystack): mixed`
Searches an array for a value based on a dot notated string of keys
| Argument | Type | Default | Description |
|-------------|----------|---------|------------------------------|
| `$needle` | `string` | n/a | A dot separated list of keys |
| `$haystack` | `array` | n/a | The array to traverse |
> :bulb: `p810\Dot\search()` is an alias for this function
#### `p810\Dot\getKeysFromString(string $keys): array`
Returns a list of keys from a dot notated string
| Argument | Type | Default | Description |
|----------|----------|---------|------------------------------|
| `$keys` | `string` | n/a | A dot separated list of keys |
## License
This package is released under the [MIT License](https://github.com/p810/Dot/blob/master/LICENSE).