|
Posted by ZeldorBlat on 05/24/07 19:24
On May 24, 10:51 am, "cluthz" <WHATEEVVE...@by.co.uk> wrote:
> I've lived with print_r printing my array variable output on a single
> wrapped line for some time now.
>
> But I now want to know how to make print_r print an array on multiple lines
> making it easier to read.
>
> I have tried to google this but difficult to know what keywords to use and
> thus have not found good results.
>
> Does anyone know how I can do this?
>
> Thanks in advance.
Well, it does print them on multiple lines. You're probably looking
at it through a browser, though, which ignores newlines.
What you really need to do is capture the output of print_r, then use
nl2br before echo'ing it out. If you specify true for the second
argument to print_r the result will be returned rather than echo'd
out. So, something like this:
$a = array('foo' => 'bar', 'baz' => 'xyzzy');
echo nl2br(print_r($a, true));
Navigation:
[Reply to this message]
|