2

How do you output an array with FirePHP?

I'm using FirePHP in a Zend Framework project. I can output the value of individual variables with:

$logger->log('foo = '.$foo, Zend_Log::INFO);

and see something like:

foo = "Ponies!"

However if $foo is an array I only see:

foo = Array

and the word Array is not clickable or hoverable or anything.

I googled Google and my googling didn't return anything about how to output the values in an array with FirePHP. Any ideas?

rg88
  • 20,742
  • 18
  • 76
  • 110

2 Answers2

6

It doesn't have much to do with FirePHP, it's because you're concatenating the array to a string: 'foo = '.$foo. At this point PHP has to cast the array to a string, which results in the string "Array". If you'd just do $logger->log($foo), the array would probably be expanded automatically (depending on how intelligent the logger class is, most do this kind of thing).

If you need to expand the array manually, use var_export($foo, true).

deceze
  • 510,633
  • 85
  • 743
  • 889
  • And that did it. I didn't even consider that concatenating the array to a string would cast it as such. Makes sense but I just glossed right over that, mentally. Thanks! – rg88 Oct 15 '10 at 03:11
  • FirePHP also supports special formatters. Check out the "Setting Styles" section on the docs page; http://framework.zend.com/manual/en/zend.log.writers.html – Darryl E. Clarke Nov 05 '10 at 21:42
0

you can use implode function which provide the way join array to string

$arr_str = implode(',', $arr);
$this->firephp->log($arr_str);

firephp is just a logger, which trace output is not it's point