php中如何格式化数组?
我有一个数组 $array
,它打印出如下内容:
Array
(
[Terry] => Array
(
[2011-10-26] => Array
(
[0] => 69.90
[1] => 69.90
)
)
[Travis] => Array
(
[2011-10-26] => Array
(
[0] => 199.50
)
[2011-10-27] => Array
(
[0] => 199.50
)
)
)
我正在尝试将数据放入这样的表中:
NAME 2011-10-26 2011-10-27
Terry 2 0
Travis 1 1
我可以得到这样的计数:
foreach($array as $key => $value){
echo $key; // this will give me the names
foreach($value as $keys => $values){
echo $keys; //this will give me the dates
echo count($values); // this will give me the count per date
}
}
我得到的日期是这样的:< code>2011-10-26 2011-10-26 2011-10-27
我已经玩了一段时间了,但我已经没有想法了。
有什么帮助吗?
谢谢
i have an array $array
that prints out something like:
Array
(
[Terry] => Array
(
[2011-10-26] => Array
(
[0] => 69.90
[1] => 69.90
)
)
[Travis] => Array
(
[2011-10-26] => Array
(
[0] => 199.50
)
[2011-10-27] => Array
(
[0] => 199.50
)
)
)
i am trying to place data into a table like this:
NAME 2011-10-26 2011-10-27
Terry 2 0
Travis 1 1
i can get the count like this:
foreach($array as $key => $value){
echo $key; // this will give me the names
foreach($value as $keys => $values){
echo $keys; //this will give me the dates
echo count($values); // this will give me the count per date
}
}
the dates that i get back are like this: 2011-10-26 2011-10-26 2011-10-27
I've been playing with this for a while and i run out of ideas.
any help?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
结果:
The result: