2017 © Pedro Peláez
 

library arr

The Array Component contains methods that can be useful when working with arrays.

image

flextype-components/arr

The Array Component contains methods that can be useful when working with arrays.

  • Thursday, May 31, 2018
  • by Awilum
  • Repository
  • 1 Watchers
  • 0 Stars
  • 103 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 49 % Grown

The README.md

Arrays Component

Version License Total downloads Quality Score , (*1)


, (*2)

Installation

With Composer:, (*3)

composer require flextype-components/arrays

Usage

use Flextype\Component\Arrays;

Methods

Method Description
Arrays::set() Set an array item to a given value using "dot" notation. If no key is given to the method, the entire array will be replaced.
Arrays::get() Returns value from array using "dot notation". If the key does not exist in the array, the default value will be returned instead.
Arrays::delete() Deletes an array value using "dot notation".
Arrays::has() Checks if the given dot-notated key exists in the array.
Arrays::dot() Flatten a multi-dimensional associative array with dots.
Arrays::undot() Expands a dot notation array into a full multi-dimensional array.

Method: Arrays::set()

Set an array item to a given value using "dot" notation. If no key is given to the method, the entire array will be replaced., (*4)

Arrays::set($array, 'movies.the-thin-red-line.title', 'The Thin Red Line');

Method: Arrays::get()

Returns value from array using "dot notation". If the key does not exist in the array, the default value will be returned instead., (*5)

Arrays::get($array, 'movies.the-thin-red-line.title')

Method: Arrays::delete()

Deletes an array value using "dot notation"., (*6)

Arrays::delete($array, 'movies.the-thin-red-line');

Method: Arrays::has()

Checks if the given dot-notated key exists in the array., (*7)

if (Arrays::has($array, 'movies.the-thin-red-line')) {
    // Do something...
}

Method: Arrays::dot()

Flatten a multi-dimensional associative array with dots., (*8)

$array = [
            'movies' => [
                'the_thin_red_line' => [
                    'title' => 'The Thin Red Line',
                    'directed_by' => 'Terrence Malick',
                    'produced_by' => 'Robert Michael, Geisler Grant Hill, John Roberdeau',
                    'decription' => 'Adaptation of James Jones autobiographical 1962 novel, focusing on the conflict at Guadalcanal during the second World War.',
                ],
            ],
         ];

$newArray = Arrays::dot($array);

Method: Arrays::undot()

Expands a dot notation array into a full multi-dimensional array., (*9)

$array = [
            'movies.the_thin_red_line.title' => 'The Thin Red Line',
            'movies.the_thin_red_line.directed_by' => 'Terrence Malick',
            'movies.the_thin_red_line.produced_by' => 'Robert Michael, Geisler Grant Hill, John Roberdeau',
            'movies.the_thin_red_line.decription' => 'Adaptation of James Jones autobiographical 1962 novel, focusing on the conflict at Guadalcanal during the second World War.',
         ];

$newArray = Arrays::undot($array);

License

The MIT License (MIT) Copyright (c) 2020 Sergey Romanenko, (*10)

The Versions

31/05 2018

dev-master

9999999-dev https://github.com/flextype-components/arr

The Array Component contains methods that can be useful when working with arrays.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

array

31/05 2018

v1.2.3

1.2.3.0 https://github.com/flextype-components/arr

The Array Component contains methods that can be useful when working with arrays.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

array

30/04 2018

v1.2.2

1.2.2.0 https://github.com/flextype-components/arr

The Array Component contains methods that can be useful when working with arrays.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

array

26/04 2018

v1.2.1

1.2.1.0 https://github.com/flextype-components/arr

The Array Component contains methods that can be useful when working with arrays.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

array

26/04 2018

v1.2.0

1.2.0.0 https://github.com/flextype-components/arr

The Array Component contains methods that can be useful when working with arrays.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

array

11/04 2018

v1.1.1

1.1.1.0 https://github.com/flextype-components/array

The Array Component contains methods that can be useful when working with arrays.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

array

05/04 2018

v1.1.0

1.1.0.0 https://github.com/flextype-components/array

The Array Component contains methods that can be useful when working with arrays.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

array

27/10 2015

v1.0.2

1.0.2.0 https://github.com/force-components/Arr/issues

Simple Array Class

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

array