I am trying to create a function that returns the contents of an array as a string. It should accept arrays of any dimension. It is not working very well, but I got this far:
function show($variable, $buffer){
if (is_array($variable)){
foreach($variable as $key => $value){
$buffer = $buffer.$key."<br>";
return show($value, $buffer);
}
}
else{
return $buffer.$variable."<br>";
}
}
$fruit = array('banana', 'orange', 'pear');
$peas = array('yellow peas', 'green peas', 'black-eyed peas');
$berries = array('blueberries', 'strawberries', 'raspberries');
$DArray = array('fruit' => $fruit, 'peas' => $peas, 'berries' => $berries);
echo show($DArray, '');
Any suggestions anyone?