tastro Posted September 16, 2011 Share Posted September 16, 2011 is there a way to reset the array keys? to 0,1,2,3,... also for example that i have something like this: $array['dog']='dog'; $array['mouse']='mouse'; $array['cat']='cat'; and i want it like this: $array[0]='dog'; $array[1]='mouse'; $array[2]='cat'; is there a function for that already in php? Quote Link to comment https://forums.phpfreaks.com/topic/247309-is-there-a-way-to-reset-the-array-keys-to-0123/ Share on other sites More sharing options...
trq Posted September 16, 2011 Share Posted September 16, 2011 is there a way to reset the array keys? to 0,1,2,3,... Reset them to what? Do you have an array with holes in it's keys? also for example that i have something like this: $array['dog']='dog'; $array['mouse']='mouse'; $array['cat']='cat'; and i want it like this: $array[0]='dog'; $array[1]='mouse'; $array[2]='cat'; is there a function for that already in php? array_values. It's probably best to refer to the manual for these types of questions rather than posting here and waiting for a reply. there is an entire section on the array functions: http://php.net/manual/en/ref.array.php Quote Link to comment https://forums.phpfreaks.com/topic/247309-is-there-a-way-to-reset-the-array-keys-to-0123/#findComment-1270144 Share on other sites More sharing options...
tastro Posted September 16, 2011 Author Share Posted September 16, 2011 thanks thorpe. problem solved. lol, array_values() does it. exactly what i needed. Quote Link to comment https://forums.phpfreaks.com/topic/247309-is-there-a-way-to-reset-the-array-keys-to-0123/#findComment-1270146 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.