首页 > 解决方案 > 如何使用 PHP 重新设置关联数组的键?

问题描述

假设我有以下来自此变量的数组:

echo '<pre>';
    print_r(json_decode($mul_from));
 echo '</pre>'

stdClass Object
(
    [0] => Array
        (
            [0] => from 1
            [1] => from 1
            [2] => from 1
            [3] => from 1
            [4] => from 1
        )

    [1] => Array
        (
            [0] => from 2
            [1] => from 2
            [2] => from 2
            [3] => from 2
            [4] => from 2
        )

    [3] => Array
        (
            [0] => 5
            [1] => from 3
            [2] => from 3
            [3] => from 3
        )

)

如何将密钥重新设置为 0 1 2 3 等等?目前,它显示 0 1 3

标签: php

解决方案


推荐阅读