我如何倾倒阵列在一个不错的有序的方式? [英] How do I dump arrays in a nice orderly fashion?

查看:115
本文介绍了我如何倾倒阵列在一个不错的有序的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我使用的print_r 的var_dump 他们出来都马虎不得,在一个行,而不是格式化像我看如此多的人与实际php.net网站能够实现的。我该怎么办,让他们这样的 -

Whenever I use print_r or var_dump they come out all sloppy and in one line instead of formatted like I see so many people and the actual php.net site being able to achieve. What do I do to get them like this -

Array
(
    [a] => apple
    [b] => banana
    [c] => Array
        (
            [0] => x
            [1] => y
            [2] => z
        )
)

取而代之的是

Array([a] => apple [b] => banana [c] => Array ( [0] => x [1] => y [2] => z ))

(pretty确保它出来,甚至混乱比我只是用手工删除空格。)

(Pretty sure it comes out even messier than that I was just deleting whitespace by hand.)

推荐答案

只是包装您的转储在< pre> 标签:

Just wrap your dumps in <pre> tags:

<pre><?php print_r($array); ?></pre>

此外,如果您查看页面的源代码将是所有pretty这样了。这只是因为HTML忽略空格,你看到这一切在一行在浏览器中。

Also, if you view the source of your page it will be all pretty like this, too. It's just because HTML ignores whitespace that you see it all on one line in your browser.

这篇关于我如何倾倒阵列在一个不错的有序的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆