-2

Possible Duplicate:
php array re populate keys

is there a way to remove all the non-existing indexes from a php array and then rearrange it? For example

Array
(
    [0] => a
    [2] => b
    [3] => c
    [6] => d
)

TO

Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
)

Big thanks! Rik.

0

2 Answers 2

5

Just use this built-in function

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

Comments

3

Use array_values.

$arr = array_values($arr);

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.