Substitute for print_r and var_export
Moderator: General Moderators
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
Substitute for print_r and var_export
Is there any command or known small nice function that outputs arrays etc. nicely categorized with tabs or emphasized by html.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
<?php
echo '<pre> '. print_r($array) .'</pre>';
?>-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
I made something handy for printing classes with (multi-D)arrays in them.
Outputs:
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'