FirePHP array indentation

8 views
Skip to first unread message

fud...@gmail.com

unread,
Feb 8, 2007, 6:07:57 AM2/8/07
to FirePHP
On my FirePHP output, I don't have a proper indentation of the PHP
array like on
http://www.firephp.org/Demo/

I get a simple "flat" array like this :

Array ( [login_challenge] => 225289d4970f55a16a043d42786a5a12 [Frame1]
=> Array ( [0] => [1] => [2] => ) )

How can I change this ? Thank you !

Christoph Dorn

unread,
Feb 8, 2007, 11:23:27 AM2/8/07
to FirePHP
The variable output is generated with a custom function I use. I have
included it below.

You can use it like this:

p($_SESSION,'$_SESSION');

-------------------
function p($msg,$name='',$Padding=0) {

$padding_str = str_pad('',$Padding,' ');

if(is_object($msg)) {

if($vars = get_object_vars($msg)) {

print('<span style="background-color: #FFCC00"><font
color="#800000" face="Verdana" size="2"><b>[');
if($name!='') {
print('<font color="#000000">'.$name.'</font> #
'.get_class($msg).' # ');
} else {
print(' # '.get_class($msg).' # ');
}

print '<table border="1" cellpadding="1">';

foreach($vars as $name => $value) {

print '<tr>
<td>';

p($value,$name);

print '</td>
</tr>';
}

print '</table>';

} else {

p('Object (no vars)',$name);
}

print('</font>] END OBJECT</b></font></span><br>'."\n");

} else {

print('<span style="background-color: #FFFFFF"><font
color="#00CC00" face="Verdana" size="2"><b>[');
if($name!='') print('<font color="#000000">'.$name.'</font> #
');
print('<font color="#000000">');

if(gettype($msg)=='array') {

print('<pre>');

var_dump($msg);

print('</pre>');
} else {
print htmlentities($msg);
}
print '</font>]</b></font></span><br/>'."\n";
}
}
-------------------


fud...@gmail.com

unread,
Feb 9, 2007, 3:48:26 AM2/9/07
to FirePHP
Thank's very much for the support ! It's cool now :)

daza21

unread,
Mar 7, 2007, 8:07:15 AM3/7/07
to FirePHP
I found this code and adapted it it to give the output as a table:

function array_to_table($ay,$Colour='#a0f0f0')
{
if(count($ay)==0){
return("No elements in array<br>\n");
exit;
}

$firstrow=TRUE;
$t="<br><table bgcolor=$Colour border=1>";
foreach($ay as $k=>$a){
if($firstrow){
if(is_array($a)){
$t .= "<tr><td> </td>";
foreach($a as $r=>$v){$t .= "<td><b>$r</b></td>";}
$t .= "</tr>\n";
$firstrow=FALSE;
}
}

$t .= "<tr>";
$t .= "<td><b>$k</b></td>";
if(is_array($a)){
foreach($a as $v){
if(!$v){
$v='<pre> </pre>';
}else{
if(is_object($v)){
$v='<i>'.get_class($v).'</i>';
}
}
$t .= "<td>$v</td>";
}
}else{
if(!$a){
$a='';
}else{
if(is_object($a)){
$a='<i><font color=blue>'.get_class($a).'</font></i>';
}
}
$t .= "<td>$a</td>";
}
$t .= "</tr>\n";
}
$t .= '</table><br>';
return $t;
}

Christoph Dorn

unread,
Mar 7, 2007, 12:48:11 PM3/7/07
to Fir...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages