PHPackages                             selective/array-reader - 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. selective/array-reader

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

selective/array-reader
======================

A strictly typed array reader

2.3.0(2mo ago)1168.7k↓24.2%54MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Oct 19Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/selective-php/array-reader)[ Packagist](https://packagist.org/packages/selective/array-reader)[ Docs](https://github.com/selective-php/array-reader)[ RSS](/packages/selective-array-reader/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (10)Versions (10)Used By (4)

selective/array-reader
======================

[](#selectivearray-reader)

A strictly typed array reader for PHP.

[![Latest Version on Packagist](https://camo.githubusercontent.com/fb12963da032a5558592228612db2b7dd446fefeadd56167bff8f3d480cc6ae5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73656c6563746976652d7068702f61727261792d7265616465722e737667)](https://packagist.org/packages/selective/array-reader)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Build Status](https://github.com/selective-php/array-reader/workflows/build/badge.svg)](https://github.com/selective-php/array-reader/actions)[![Total Downloads](https://camo.githubusercontent.com/f089a1cee1d5019ab4f407b982f80076ed529db56077cf15f9b1637b613407dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73656c6563746976652f61727261792d7265616465722e737667)](https://packagist.org/packages/selective/array-reader/stats)

Requirements
------------

[](#requirements)

- PHP 8.2 - 8.5

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

[](#installation)

```
composer require selective/array-reader
```

Usage
-----

[](#usage)

You can use the `ArrayReader` to read single values from a multidimensional array by passing the path to one of the `get{type}()` and `find{type}()` methods.

Each `get*() / find*()` method takes a default value as second argument. If the path cannot be found in the original array, the default is used as return value.

A `get*()` method returns only the declared return type. If the default value is not given and the element cannot be found, an exception is thrown.

A `find*()` method returns only the declared return type or `null`. No exception is thrown if the element cannot be found.

```
