php 如何打印数组的所有值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5528097/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 21:42:52 来源:igfitidea点击:
How can I print all the values of an array?
提问by John Doe
I have an array and print_r won't display the raw text, how can I print all the values in an array (e.g. pie)
我有一个数组,print_r 不会显示原始文本,如何打印数组中的所有值(例如饼图)
回答by deceze
So many ways to do it...
有很多方法可以做到...
foreach ($array as $item) {
echo $item;
}
echo join(', ', $array);
array_walk($array, create_function('$a', 'echo $a;'));
回答by karim79
Maybe you just need some <pre>
tags:
也许你只需要一些<pre>
标签:
echo '<pre>';
print_r($arr);
echo '</pre>';
回答by Sourav
<?php
$len=count($pie);
for ($i=0;$i<$len;$i++)
echo $pie[$i];
?>