douyi6922 2014-03-14 21:10
浏览 38

使用带数组的foreach循环[关闭]

I have an array represent by $details_sort.

I want to use my array in foreach loop.

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

        )

)
  • 写回答

2条回答 默认 最新

  • drwpbrv668670 2014-03-14 21:18
    关注
    foreach($details_sort as $detail) {
        foreach($detail as $attribute => $value) {
            echo "$attribute => $value";
        }
    }
    

    or

    foreach($details_sort as $detail) {
        echo $detail['id'];
        echo $detail['score'];
        echo $detail['userid'];
        echo $detail['date'];
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度