- var_export: documentation ( source)
- str_replace: documentation ( source)
<?php
$arr = [
'key' => 'value',
'mushroom' => [
'badger' => 1
]
];
$output = var_export($arr, true);
echo $output;
$output = str_replace(array('array (', ')'), array('[',']'), $output);
echo $output;