-1

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);
4
  • I'm not sure I'm following you, but couldn't you just use range(1, 14) instead? Commented Oct 30, 2015 at 10:52
  • You want the keys to be 1 - 14? Commented Oct 30, 2015 at 10:52
  • if I start at 1 the array index still starts at 0 => 1. I want to start it like this 1=> 1 Commented Oct 30, 2015 at 11:07
  • I got the question, but its just ridiculously bad explained, and the second example is same as first FYI or im blind, you're lucky people are still willing to answer :P Commented Oct 30, 2015 at 11:35

3 Answers 3

5

You can also go for :

$numbers = range(0, 14);

array_unshift($numbers,"");
unset($numbers[0]);
Sign up to request clarification or add additional context in comments.

Comments

2

You could try this:

$numbers = array_combine(range(1,14), range(1,14));

Comments

1

Try this code These will help you

$data = array_slice(range(0,12), 1, null, true);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.