2017 © Pedro Peláez
 

library ex

A PHP function to safely extract information from a multi-dimensional object or array.

image

travis/ex

A PHP function to safely extract information from a multi-dimensional object or array.

  • Tuesday, February 14, 2017
  • by car6on
  • Repository
  • 2 Watchers
  • 2 Stars
  • 139 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

Extraction

A PHP function to safely extract information from a multi-dimensional object or array., (*1)

Install

Normall install via Composer., (*2)

Usage

$array = array(
    'foo' => array(
        'bar' => array(
            'foo' => array(
                'bar' => 'asdf'
            )
        )
    )
);

$value = ex($array, 'foo.bar.foo.bar'); // returns "asdf"
$value = ex($array, 'foo.bar.foo.invalid_key'); // returns null
$value = ex($array, 'foo.bar.foo.invalid_key', 'default'); // returns "default"

Updates

I added another helper function to safely count arrays:, (*3)

$array = null;
$count = excount($array); // returns 0 instead of error

I wanted this to fix a change in PHP 7.4 which breaks sizeof()., (*4)

The Versions

14/02 2017

dev-master

9999999-dev https://github.com/swt83/php-ex

A PHP function to safely extract information from a multi-dimensional object or array.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Scott Travis

14/02 2017

v1.0.0

1.0.0.0 https://github.com/swt83/php-ex

A PHP function to safely extract information from a multi-dimensional object or array.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Scott Travis