Reindex多维数组从1个索引到0索引为基础[关闭]

Array
(
    [1] => Array
        (
            [1] => 1
            [2] => 2
        )

    [2] => Array
        (
            [1] => 1
            [2] => 2
        )

    [3] => Array
        (
            [1] => 1
        )

)

I want to change internal array key its start from 0 and 1 not [1]= 1

foreach($outerArray as $key => $innerArray)
{
    $outerArray[$key] = array_values($innerArray);
}

Here's something recursive for funzies:

function resetKeys(array &$array) {
     $array = array_values($array);
     foreach($array as &$value) {
         if(is_array($value)) { 
             resetKeys($value);
         }
     }
}

Here it is working:

$array = [
    '1' => [
        '1' => '1'
     ]
];
resetKeys($array);
print_r($array);

Result:

Array
(
    [0] => Array
        (
            [0] => 1
        )
)

See the manual entry for array_values

To use it without changing the outer values:

foreach($array as &$value) {
    resetKeys($value);
}
print_r($array);

Result:

Array
(
    [1] => Array
        (
            [0] => 1
        )
)