Fearghal
Fearghal

Reputation: 263

php array key issue

ok so i have the following array:

0 - 208533

1 - 208523

2 - 208522

3 - 208572

4 - 208518

5 - 208501

6 - 208534

7 - 208499

All i need is a quick function that'll start the array key at 1 rather than 0.

eg: 1 - 208533 etc

Any ideas?

Thanks!

Upvotes: 0

Views: 67

Answers (1)

reko_t
reko_t

Reputation: 56430

Well one quick way to do it is:

array_unshift($array, null); // inject a dummy value at beginning
unset($array[0]); // unset the dummy value, the rest of the keys are preserved

Upvotes: 3

Related Questions