Use error_log with array in php
Sends an error message to the web server's error log or to a file.
Using print_r() is the easiest, since the second parameter to the function says that we want to send the output to a variable rather than echoing it. Thus, to write to the error_log you just need to use the following code.
you must set that print_r() option to “true” so that it returns a string. This string is then sent to the error_log() function which formats it with referrer details and puts it into the Apache error log.
# Notify by mail error_log(print_r($data,true), 1, "email@example.com"); # Send notification through server log error_log(print_r($data,true), 0,); # Send notification to log file error_log(print_r($data,true), 3, "var/tmp/error.log");