I know I can print an array using print_r() function in PHP like this
print_r($array);
And to make it look pretty in the browser, I can wrap it up with the HTML <pre> block like this
echo '<pre>';
print_r($array);
echo '</pre>';
But, how can I write the second nice output to a file not to a browser using HTML?
Here is what I have tried
$file = fopen('test.log', 'a+');
fwrite($file, print_r($this->header, TRUE) . PHP_EOL);
fclose($file);
But, that does not write the array's content nicely in the test.log file. it writes it as a data dump which is hard to read.
How can I nicely print the array content for easy read
newlineand first alphanumerical character with\t(tabulator). This should create nice indents.