Substitute for print_r and var_export
Posted: Fri Dec 03, 2004 10:48 am
Is there any command or known small nice function that outputs arrays etc. nicely categorized with tabs or emphasized by html.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
echo '<pre> '. print_r($array) .'</pre>';
?>That's what i have in mind, but i assumed it's done and used countless times before, so that's why i asked.protokol wrote:You could always write one that parses the values returned from those functions and uses pretty colors.
Code: Select all
$needles=array( "{" , ";" , "(" , "," , ")" , "}" );
$replace=array( "<BLOCKQUOTE>" , "<BR><BR>" , "<BLOCKQUOTE>" , "<BR>", "</BLOCKQUOTE>" , "</BLOCKQUOTE>");
echo str_replace($needles, $replace, var_export($units,1));Code: Select all
class cUnits
public $unit_static = NULL
public $unit = array
1 => array
'type_id' => '1'
'name_number' => '1'
'name' => 'Moonguard #1'
'strength' => '1000'
'x' => '10'
'y' => '50'
2 => array
'type_id' => '1'
'name_number' => '2'
'name' => 'Moonguard #2'
'strength' => '1000'
'x' => '11'
'y' => '50'
4 => array
'type_id' => '1'
'name_number' => '3'
'name' => 'Combined skirmish force of the Wise'
'strength' => '0'
'x' => '0'
'y' => '0'