I\'m new to PHP, and don\'t have quite the grip on how it works. If I have a two dimensional array as such (returned by a database):
array(3) {
[0]=&
You asked for a two-dimensional array, here's a function that will work for multidimensional array.
function implode_r($g, $p) {
return is_array($p) ?
implode($g, array_map(__FUNCTION__, array_fill(0, count($p), $g), $p)) :
$p;
}
I can flatten an array structure like so:
$multidimensional_array = array(
'This',
array(
'is',
array(
'a',
'test'
),
array(
'for',
'multidimensional',
array(
'array'
)
)
)
);
echo implode_r(',', $multidimensional_array);
The results is:
This,is,a,test,for,multidimensional,array