Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php Convert multidimensional array into single array

function array_flatten($array) { 
  if (!is_array($array)) { 
    return FALSE; 
  } 
  $result = array(); 
  foreach ($array as $key => $value) { 
    if (is_array($value)) { 
      $result = array_merge($result, array_flatten($value)); 
    } 
    else { 
      $result[$key] = $value; 
    } 
  } 
  return $result; 
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #Convert #multidimensional #array #single #array
ADD COMMENT
Topic
Name
9+8 =