Pergunta

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?

Foi útil?

Solução

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).

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top