i have this array
$array =array('a', 'b', array(array('c'), 'd'), 'e', array('f'), 'g');
i want to have as result this
Array
(
[0] => a
[1] => b
[2] => c
[3] => d
[4] => e
[5] => f
[6] => g
)
I am using this function :
function flatten ($array) {
$result = array();
array_walk_recursive($array, function($v, $k) use (&$result) {
$result[] = $v;
});
return $result;
}
i am getting this result :
Array
(
[0] => array('a', 'b',
[1] => array(array('c'), 'd'),
[2] => 'e', array('f'), 'g')
)
which the same as the original input array.
any help would be appreciated