0

I am not sure if these are the correct words to express my query. I have the following array, result of filtration stage. As you can see the keys are not consecutive [e.g. 2,3,5,7 etc]. is there any php function that will automatically re-structure the keys for me (like, the first key is 0 and then consecutive 1,2,3 etc.)? sort() function does not help and I also tried several other PHP array sorting functions but none helped.

Array
(
    [2] => RP/
    [3] => LONU1
    [5] => 1.ISL
    [7] => 2.KHO
    [9] => 3.KHO
    [11] => 4.RUMA/
    [12] => 5  EK
    [13] => 6  EK 582
    [14] => 7  E
    [15] => 8  EK 011 L
)
2
  • array_values maybe? sort would have done it, of course it would have also sorted. Commented Oct 22, 2014 at 16:53
  • @AbraCadaver : Yes, that's right. array_values() has done it. Thanks a lot. Commented Oct 22, 2014 at 17:08

1 Answer 1

2

array_values is your friend.

$array = array_values($array);

Source

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.