Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

array_flatten php

/**
 * Function converts multidimentional array to a plain one
 *
 * @param $arr multidimensional array
 *
 * @return array
 */
function array_flatten($arr) {
    $return = [];
    foreach ($arr as $key => $value) {
        if (is_array($value)) {
            $return = array_merge($return, array_flatten($value));
        } else {
            $return[] = $value;
        }
    }
    return $return;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php
ADD COMMENT
Topic
Name
6+6 =