Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
function toString($value): string
{
return trim(var_export($value, true), "'");
}
function stringify($data)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
echo $k . ': ' . toString($v) . "\n";
}
} else {
echo $key . ': ' . toString($value) . "\n";
}
}
}
$data = [
'hello' => 'world',
'is' => true,
'nested' => ['count' => 5],
];
print_r(stringify($data));