I have a multidimentional array (MyArray), and want to "linearize" it to a string. So I try with this recursive function:
function RecursiveFunction($TheArray){
foreach($TheArray as $key => $value){
if(is_array($value)){
$RecursiveOutput.="(".$key.")";
RecursiveFunction($value); //-->this does't seem to work
} else {
$RecursiveOutput.="(".$value.")";
}
}
return $RecursiveOutput;
}
echo RecursiveFunction($MyArray);
However, I'm getting the keys from the first level of the array only: the recursive recall doesn't seem to work. Can anyone spot the problem?
$RecursiveOutputbut you aren't catching the return value.$RecursiveOutput .= "(".$key.")"."(".RecursiveFunction($value).")";$RecursiveOutput .= "(".$key.")"."(".RecursiveFunction($value).")";. Post as an answer for accepting. Thanks a lot!