how to array key start from 1 instead of 0?

2019-03-06 19:55发布

How do I start the array of a range at 1 instead of 0, Code looks like this:

    $numbers = range(0, 14);

I tried this but that does not solve my problem

    $numbers = range(0, 14);

标签: php arrays range
3条回答
【Aperson】
2楼-- · 2019-03-06 20:15

You could try this:

$numbers = array_combine(range(1,14), range(1,14));
查看更多
一纸荒年 Trace。
3楼-- · 2019-03-06 20:16

Try this code These will help you

$data = array_slice(range(0,12), 1, null, true);
查看更多
男人必须洒脱
4楼-- · 2019-03-06 20:26

You can also go for :

$numbers = range(0, 14);

array_unshift($numbers,"");
unset($numbers[0]);
查看更多
登录 后发表回答