Sometimes we want to store php array in file for debugging or examination purpose.
One way for this is to capture all the values (including array ) in buffer and later print on a file:
For example:

ob_start(); // Start buffering
print_r($arrValue); // Print the value of array. We can also use var_dump just as per our need.
$getValues = ob_get_clean(); // Capture the value in a php variable.
// Write the conent in required file.
error_log(” Data ::”.$getValues.” \n\”, 3, “/path/to/destination/directory/log-file-name”);

Leave a Reply

Your email address will not be published. Required fields are marked *