2

I am trying to auto-increment an array and here below is code.

Array
(
    [0] => 22
    [2] => 33
)

I want this to be printed as

Array
(
    [0] => 22
    [1] => 33
)

The autoincrement should be done in this way. How can I achieve this?

0

1 Answer 1

3

Easiest way:

$incrementedArray = array_values($yourArray);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.