I have an array which is multidimensional for no reason
/* This is how my array is currently */
Array
(
[0] => Array
(
[0] => Array
Following this pattern
$input = array(10, 20, array(30, 40), array('key1' => '50', 'key2'=>array(60), 70));
Call the function :
echo "";print_r(flatten_array($input, $output=null));
Function Declaration :
function flatten_array($input, $output=null) {
if($input == null) return null;
if($output == null) $output = array();
foreach($input as $value) {
if(is_array($value)) {
$output = flatten_array($value, $output);
} else {
array_push($output, $value);
}
}
return $output;
}