I am trying to get all values of multidimensional array like this
$post = array(
'k'=>'kk',
'l'=>'ll',
'n'=>array(
't'=>'tt',
'n'=>array(
'j'=>'jj',
'h'=>'hh'
)
)
);
My approach to do that is :
$ordered = array();
foreach($post as $key=>$value){
if(!is_array($value)){
$ordered[] = $value;
}else{
$r = array_walk_recursive($value, function($v,$k) use(&$ordered){
$ordered[] =$v;
});
}
}
Expected output:
Array
(
[0] => kk
[1] => ll
[2] => tt
[3] => jj
[4] => hh
)
i don't know if it's the best solution for it , i am consider the performance and backward compatibility with older php