note 95700 modified in function.var-export by danbrown

From: Date: Sun, 17 Jan 2010 02:38:58 +0000
Subject: note 95700 modified in function.var-export by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165039@lists.php.net to get a copy of this message
I didn't see this simple little item anywhere in the user notes. Maybe I'm blind! Anyway, var_export and print_r both use spaces and carriage returns for formatting. Sent to an html page, most of the formatting is lost. This simple function prints a nicely formatted array to an html screen: <?php function pretty_var($myArray){ print str_replace(array("\n"," "),array("<br>","&nbsp;"), var_export($myArray,true))."<br>"; } ?> --was-- I didn't see this simple little item anywhere in the user notes. Maybe I'm blind! Anyway, var_export and print_r both use spaces and carriage returns for formatting. Sent to an html page, most of the formatting is lost. This simple function prints a nicely formatted array to an html screen: function pretty_var($myArray){ print str_replace(array("\n"," "),array("<br>","&nbsp;"), var_export($myArray,true))."<br>"; } http://php.net/manual/en/function.var-export.php

« previous php.notes (#165039) next »