rmbarnes82 Posted July 10, 2008 Share Posted July 10, 2008 Hi, Does anyone know of a php function to re-key an array with sequential integers starting at 0? For example, lets say the function to do this is called array_rekey(): <?php $myArray = array(3=>'a', 8=>'b', 102=>'c'); array_rekey($myArray); print_r($myArray); ?> I am of course assuming here that the function takes the array by reference, and so the ouput would be: Array ( [0] => 'a' [1] => 'b' [2] => 'c' ) array_fill_keys() won't work for this. If there isn't a function that already exists to do this, please ignore. Thanks, Robin Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 10, 2008 Share Posted July 10, 2008 $new_array = array_values($myArray); Quote Link to comment Share on other sites More sharing options...
rmbarnes82 Posted July 10, 2008 Author Share Posted July 10, 2008 ty Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 10, 2008 Share Posted July 10, 2008 Any time. =) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.