PHPackages                             axetools/dot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. axetools/dot

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

axetools/dot
============

A PHP Library to access ans set values in an array using dot notation on any other separator

v1.0.0(1y ago)03.8k↓89%[1 issues](https://github.com/AxeTools/Dot/issues)MITPHPPHP ^5.6 || ^7.0 || ^8.0CI passing

Since Oct 7Pushed 5mo agoCompare

[ Source](https://github.com/AxeTools/Dot)[ Packagist](https://packagist.org/packages/axetools/dot)[ RSS](/packages/axetools-dot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (4)Used By (0)

axetools/dot
============

[](#axetoolsdot)

[![Latest Version](https://camo.githubusercontent.com/d82209edb38421a666cf66601adc69a70c043a7a2b4d4c356eb65623fc5397b7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617865746f6f6c732f646f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/axetools/dot)[![Total Downloads](https://camo.githubusercontent.com/baf5b092a50d6214f812ddae843a159ec0a4ff0a1f1726c8c0e9ccf5492930c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617865746f6f6c732f646f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/axetools/dot)[![Build Status](https://camo.githubusercontent.com/c26e7cfd656ee1c3a203c1ad50fe7a310ffa3eb396b257b76672aee1943aa7c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f617865746f6f6c732f646f742f7068702e796d6c3f6272616e63683d312e78267374796c653d666c61742d737175617265)](https://github.com/axetools/dot/actions?query=workflow%3Aphp+branch%31.x)

**axetools/dot** is a PHP library to access and set array values using dot notation or any other key separator.

Q: There are quite a few 'dot' projects that exist on Packagist, what is different about this one?

> Every other 'dot' project requires you to create a copy of your data and instantiate a new class, this project uses light weight static methods to access and modify your existing arrays without the need to create a second copy of the data.

> The other advantage that this has over many other implementations is that you can select an alternative key separator than a '.' which is necessary if you have key values that contain '.' characters in them.

Q: Why add this to Packagist?

> This package has been used on several of my projects both personally and professionally, and I am tired of copying the class from one project to another. If my teams and I get usage out of this project, I wanted to share it to allow anyone else who this could help use it as well.

> Warning: When you have xDebug enabled the recursion depth is set to 100, however the PHP [manual](https://www.php.net/manual/en/functions.user-defined.php#example-149) advises against doing 100-200 recursion levels as it can smash the stack and cause termination of the current script. This class utilizes recursion to traverse the array. If you need to traverse an array with depth deeper than 100 levels this likely is the wrong tool to utilize.

Installation
------------

[](#installation)

The preferred method of installation is via [Composer](http://getcomposer.org/). Run the following command to install the package and add it as a requirement to your project's `composer.json`:

```
composer require axetools/dot
```

Usage
-----

[](#usage)

The Dot class contains static methods to facilitate the safe access, setting, unsetting and counting of array data in php.

### `Dot::has()`

[](#dothas)

The `Dot::has()` checks to see if there is a value in the search array for the search key. This method utilizes recursion to traverse the array.

There is a globally available `dotHas()` function, that wraps the `Dot::has()` static method included in the autoloader.

#### Description

[](#description)

```
Dot::has(array $searchArray, string $searchKey, string $delimiter = '.'): bool

```

#### Parameters

[](#parameters)

searchArrayThe array that will be searched for the provided key valuesearchKeyThe delimited key that will be searched for in the provided searchArray. If the array does not have string keys number strings can be used instead to access the appropriate position in the arraydelimiterThe key delimiter can be specified, this is needed when there are '.' values contained within the expected array keys already#### Return Values

[](#return-values)

The method returns `true` if found and `false` if not.

#### Examples

[](#examples)

##### Example #1 simple key value lookup

[](#example-1-simple-key-value-lookup)

```
