I'm trying to print_r a large array to a file to debug it. I've tried 2 methods:
$arr = get_large_array();
file_put_contents('file.txt', print_r($arr, true));
and
$arr = get_large_array();
ob_start();
print_r($arr);
file_put_contents('file.txt', ob_get_contents());
ob_end_clean();
In both cases, file.txt
is not being created, and $arr
is being echoed just like as if I had run print_r($arr)
. What's going on here?