我有一个由$details_sort
表示的数组。
我想在foreach循环中使用我的数组。
like foreach (`$details_sort` as $detail)
{
}
Array
(
[0] => Array
(
[id] => 1
[score] => 233
[user_id] => 4
[date] => 2014-02-03 00:00:00
)
[1] => Array
(
[id] => 2
[score] => 1256
[user_id] => 5
[date] => 2014-02-05 00:00:00
)
[2] => Array
(
[id] => 4
[score] => 123
[user_id] => 7
[date] => 2014-03-04 00:00:00
)
[3] => Array
(
[id] => 3
[score] => 100
)
[4] => Array
(
[id] => 5
[score] => 8
[user_id] => 2
[date] => 2014-03-13 00:00:00
)
)
答案 0 :(得分:1)
foreach($details_sort as $detail) {
foreach($detail as $attribute => $value) {
echo "$attribute => $value";
}
}
或
foreach($details_sort as $detail) {
echo $detail['id'];
echo $detail['score'];
echo $detail['userid'];
echo $detail['date'];
}
答案 1 :(得分:0)
这真的是基本的PHP。你应该有所作为。
see php foreach
foreach ($details_sort as $detail)
{
echo $detail['id'];
echo $detail['score'];
echo $detail['user_id'];
echo $detail['date'];
}