Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数组,它的键从 0 开始向上。有没有办法重新索引数组以将键更改为从 3 而不是 0 开始?
很快就离开了我的头顶,但可能有更好的方法来做到这一点
$reindexedArray = array_combine( range(3,count($originalArray)+3), $originalArray );
$newArray = array(); foreach($myArray as $key=>$value){ $newArray[$key+3] = $value; } print_r($newArray);