-1

[EDIT: This may be a duplicate question...but I spent over 30 minutes looking for the answer to this question and did not find on stackoverflow. I would argue my question is more specific]

A standard PHP string to explode to print_r:

<?php

    $pizza  = "piece1 piece2 piece3";
    $pieces = explode(" ", $pizza);
    print_r($pieces);
?>

Does anybody know the magic of making this output:

Array ( [0] => piece1 [1] => piece2 [2] => piece3)

Turn into this:

Array
(
    [0] => piece1
    [1] => piece2
    [2] => piece3
)

Many thanks.

Tez
  • 13
  • 3

1 Answers1

1

You can do:

print "<pre>";
print_r($pizza);
print "</pre>";

Or

print nl2br(print_r($pizza, true));
Ilanus
  • 6,690
  • 5
  • 13
  • 37