Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I format (pretty print) a multi-dimensional array for debugging? [duplicate]

I've seen some online pretty print modules for code. Anyone know of one that will format a multi-dimensional array into readable display?

Example, translate this:

array(83) { [0]=> array(2) { ["name"]=> string(11) "CE2 Options" ["type"]=> string(5) "title" } [1]=> array(1) { ["type"]=> string(4) "open" } [2]=> array(5) { ["name"]=> string(8) "Template" ["desc"]=> string(638) "test description" ["id"]=> string(9) "my_theme" ["type"]=> string(14) "selectTemplate" ["options"]=> array(13) {

Into this...

array(83) { 
    [0]=> array(2) { ["name"]=> string(11) "My Options" ["type"]=> string(5) "title" } 
    [1]=> array(1) { ["type"]=> string(4) "open" } 
    [2]=> array(5) { 
        ["name"]=> string(8) "Template" 
        ["desc"]=> string(638) "Test description" 
        ["id"]=> string(9) "my_theme" 
        ["type"]=> string(14) "selectTemplate" 
        ["options"]=> array(13) { 
            [0]=> string(10) "test" 
like image 289
Scott B Avatar asked Apr 24 '26 17:04

Scott B


1 Answers

If you are dumping it to HTML document use the

<pre></pre>

it does exactly that.

like image 135
Hahihula Avatar answered Apr 27 '26 13:04

Hahihula



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!