tags:

views:

45

answers:

1

How to rearrange the array element from 0th index in the sequence to end in PHP?

UPDATED

I have an array:

$input =array{ 
                              2 => '13234390',
                              4 => '12345290',
                              5 => '21322210' 
                              }

now I want this array to be rearranged as

$input =array{ 
                              0 => '13234390',
                              1 => '12345290',
                              2 => '21322210' 
                              }
+4  A: 

With

  • array_values() returns all the values from the input array and indexes numerically the array.

Example:

$array = array_values($input);
Gordon
I s there any other way to do it... are u actually getting me.. I want rearrange the same array in proper sequence...
OM The Eternity
@OMThe well, yes. You could do `usort($input, function() { return 1; });` which would not create a copy of the array, but that's about 3 to 4 times slower.
Gordon
@Gordon pls see the updated question....
OM The Eternity
I used the array_values() but but arranged my values in ascending order.. i dont want the order of values to be changed
OM The Eternity
I got the problem.......Thankss Gordon.. U r are right....
OM The Eternity