How to increase by 1 all keys in an array?

前端 未结 6 1622
北恋
北恋 2020-12-05 07:04

What is the simplest solution to increase by 1 all keys in an array?

BEFORE:

$arr[0] = \'a\';
$arr[1] = \'b\';
$arr[2] = \'c\';
         


        
6条回答
  •  伪装坚强ぢ
    2020-12-05 07:15

    $count = count($arr);
    for($i=$count; $i>0; $i--){
        $arr[$i] = $arr[$i-1];
    }
    unset($arr[0]);
    

提交回复
热议问题