2017 © Pedro Peláez
 

library php-arrays

Helper functions for manipulating arrays

image

madesimple/php-arrays

Helper functions for manipulating arrays

  • Wednesday, May 23, 2018
  • by pdscopes
  • Repository
  • 1 Watchers
  • 2 Stars
  • 429 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 7 % Grown

The README.md

madesimple/php-arrays

PHPUnit, (*1)

Helper functions for manipulating arrays., (*2)

Arr & ArrDots

Arr and ArrDots contains a set of static helper methods for arrays. These methods can be used on both array and \ArrayAccess objects. See the PHPDocs inside the classes for more information., (*3)

Dots

Dots is an implementation of \ArrayAccess that uses the functions from \MadeSimple\ArrDots. Instances of Dots can be passed into ArrDots as if it were an array., (*4)

There are three ways to create a Dots:, (*5)

// Create an empty dot array
$dots = new \MadeSimple\Dots();

// Create a dot array with a pre-existing array
$dots = new \MadeSimple\Dots($array);

// Create a dot array with 
$dots = new \MadeSimple\Dots([
    'address' => [
        'houseNo'  => '123',
        'street'   => 'Fake St',
        'postCode' => 'AB12 3CD',
    ],
    'comments' => [
        'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
        'Donec nec pellentesque est.',
        'Quisque volutpat quam et est laoreet, vitae consectetur erat molestie.',
    ]
]);

Once a Dots is created you can replace the underlining array in the following ways:, (*6)

// Set an array after dot array
// Changes will _not_ be reflected in the original array
$dots->setArray($array);

// Set an array as a reference
// Changes will be reflected in the original array
$dots->setReference($array);

Basic usage of Dots:, (*7)

// Get a value using dot notation:
echo "Post Code: ", $dots['address.postCode'], PHP_EOL;

// Set a value using dot notation:
$dots['address.postCode'] = 'EF45 6GH';
echo "Post Code: ", $dots['address.postCode'], PHP_EOL;

// Remove a value using dot notation:
unset($dots['address.postCode']);
echo "Exists: ", (isset($dots['address.postCode']) ? 'yes' : 'no'), PHP_EOL;

// Add a value using dot notation:
$dots['address.postCode'] = 'IJ78 9KL';
echo "Post Code: ", $dots['address.postCode'], PHP_EOL;

// Access nth element in an sub array
echo "Comment: ", $dots['comments.1'], PHP_EOL;

The Versions

23/05 2018

dev-master

9999999-dev

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

16/05 2018

v2.0.0

2.0.0.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

11/05 2018

v1.3.5

1.3.5.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

11/05 2018

v1.3.4

1.3.4.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

18/10 2017

v1.3.3

1.3.3.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

27/09 2017

v1.3.2

1.3.2.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

22/09 2017

v1.3.1

1.3.1.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

15/09 2017

v1.3.0

1.3.0.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

08/09 2017

v1.2.0

1.2.0.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

30/08 2017

v1.1.0

1.1.0.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes

29/08 2017

v1.0.0

1.0.0.0

Helper functions for manipulating arrays

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Peter Scopes