How to reorder array indexes in PHP? -



How to reorder array indexes in PHP? -

this question has reply here:

php array keys reorder 3 answers

i have array follows:

array ( [0] => value1 [1] => value2 [2] => value3 [3] => value4 [4] => value5 [5] => value6 )

now somehow need unset specific key array , using unset. allow suppose removed or unset index 1. after removing index have next array:

array ( [0] => value1 [2] => value3 [3] => value4 [4] => value5 [5] => value6 )

now when loop on array 1 time again undefined index 1 error. want inquire there way can reorder array 1 time again indexes ordered? , array looks below after deletion followed reordering:

array ( [0] => value1 [1] => value3 [2] => value4 [3] => value5 [4] => value6 )

p.s: getting error because using loop , don't want utilize foreach loop because of complexity of problem. actual code problem much hard , messy understand why created dummy 1 dimensional array in question inquire problem.

so please post solutions after able iterate on same array using loop rather foreach. many thanks.

array_values should work:

$new_array = array_values($old_array);

php arrays

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -