how to change the array key to start from 1 instead of 0

后端 未结 10 2194
夕颜
夕颜 2020-12-05 02:09

I have values in some array I want to re index the whole array such that the the first value key should be 1 instead of zero i.e.

By default in PHP the array key st

10条回答
  •  粉色の甜心
    2020-12-05 02:36

    I think it is simple as that:

    $x = array("a","b","c");
    $y =array_combine(range(1, count($x)), $x);
    print_r($y);
    

提交回复
热议问题