note 73570 deleted from function.print-r by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 15:00:24 +0000 |
| Subject: | note 73570 deleted from function.print-r by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197295@lists.php.net to get a copy of this message | ||
Note Submitter: mading25 at hotmail dot com
----
None of the function to output to HTML was working for me so I had to write something that suited my
needs. It's probably super not efficient but, hey it works well for me on a small scale.
function print_r_html($data,$return_data=false)
{
$data = print_r($data,true);
$data = str_replace( " "," ", $data);
$data = str_replace( "\r\n","<br>\r\n", $data);
$data = str_replace( "\r","<br>\r", $data);
$data = str_replace( "\n","<br>\n", $data);
if (!$return_data)
echo $data;
else
return $data;
}
Simple, isn't? :)