ratacibernetica/php-flatten-array

v1.1 2017-05-19 20:40 UTC

This package is not auto-updated.

Last update: 2024-12-21 21:42:12 UTC


README

Flatten an array.

Install

composer require ratacibernetica/php-flatten-array

  1. Expected input:
[ 1, [ 2 ], [[3],[[4]]]];
  1. Expected output:
[1,2,3,4]

Example Usage:

	$multipleArray = [ 1, [ 2 ], [[3],[[4]]]];
        $flattener = new ratacibernetica\FlattenArray($multipleArray);
        $flattenedArray = $flattener->flattened;

        // equals $flattenedArray, [1,2,3,4]);

        $otherFlat = $flattener->flattenArray( [1, [2], [3], [[4],[5]]] );
        // equals( $otherFlat, [1,2,3,4,5]);

Run tests

Tests are located in the tests folder, and can be run with codeception, like so:

$ codecept run unit