多维数组如何重置索引?

wlm212
  • 46
$list=Array
(
    [total] => 3
    [per_page] => 15
    [current_page] => 1
    [last_page] => 1
    [data] => Array
        (
            [0] => Array
                (
                    [order_id] => 10065
                    [order_no] => 2020101955531001
                    [total_price] => 115.00
                )
             [2] => Array
                (
                    [order_id] => 10065
                    [order_no] => 2020101955531001
                    [total_price] => 115.00
                )
        )
) 

变成这样

$list=Array
(
    [total] => 3
    [per_page] => 15
    [current_page] => 1
    [last_page] => 1
    [data] => Array
        (
            [0] => Array
                (
                    [order_id] => 10065
                    [order_no] => 2020101955531001
                    [total_price] => 115.00
                )
             [1] => Array
                (
                    [order_id] => 10066
                    [order_no] => 2020101955531002
                    [total_price] => 65.00
                )
        )
)     

array_values,好像弄不了,试过几次,整不动。

评论
阅读 327
2 个回答
✓ 已被采纳
$list['data'] = array_values($list['data']);
撰写回答

登录后参与交流、获取后续更新提醒

宣传栏