Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Thursday, August 6, 2009

neatly print out PHP arrays

Use this function to neatly print out your arrays;

function print_r_html($data,$return_data=false) {

$data = print_r($data,true);

$data = str_replace( " "," ", $data);

$data = str_replace( "\r\n","
\r\n"
, $data);

$data = str_replace( "\r","
\r"
, $data);

$data = str_replace( "\n","
\n"
, $data);


if (!$return_data)

echo $data;

else

return $data;

}


displaying php source file


Ever wonder how to take a PHP file, and display it color coded in a web browser?

Well... Wonder no more!

PHP CLI (Command Line Interpreter) comes with this nifty feature that does this automatically for you.

php -s filename.php > filename.html

creates a html output of the php file.

Cool, ain't it?