p810/dot

A utility for traversing arrays using dot notation

4.0.0 2019-08-08 20:19 UTC

This package is auto-updated.

Last update: 2025-01-09 08:20:12 UTC


README

A utility for traversing arrays using dot notation

Installation

$ composer require p810/dot

Example usage

<?php

p810\Dot\find('foo.bar', [
    'foo' => [
        '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

💡 p810\Dot\search() is an alias for this function

p810\Dot\getKeysFromString(string $keys): array<int,string|int>

Returns a list of keys from a dot notated string

License

This package is released under the MIT License.