PHP code example of ratacibernetica / php-flatten-array

1. Go to this page and download the library: Download ratacibernetica/php-flatten-array library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ratacibernetica / php-flatten-array example snippets


[ 1, [ 2 ], [[3],[[4]]]];

[1,2,3,4]

	$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]);