What is a function in PHP used to convert array to string, other than using JSON?
I know there is a function that directly does like JSON. I just don\'t remember.
Display array in beautiful way:
function arrayDisplay($input)
{
return implode(
', ',
array_map(
function ($v, $k) {
return sprintf("%s => '%s'", $k, $v);
},
$input,
array_keys($input)
)
);
}
$arr = array('foo'=>'bar',
'baz'=>'boom',
'cow'=>'milk',
'php'=>'hypertext processor');
echo arrayDisplay($arr);
Displays:
foo => 'bar', baz => 'boom', cow => 'milk', php => 'hypertext processor'