Perad Posted June 13, 2008 Share Posted June 13, 2008 I am using unset to remove a specific array value. However this is breaking my for loops as there is a gap in the keys. What function can I use to relist keys from 0, 2, 3, 4 to 0,1,2,3? Link to comment https://forums.phpfreaks.com/topic/110062-function-to-reorganise-array-keys/ Share on other sites More sharing options...
rhodesa Posted June 13, 2008 Share Posted June 13, 2008 you can just use: $array = array_values($array); but, instead of for, use foreach...SO much easier: foreach($array as $value){ echo $value; } Link to comment https://forums.phpfreaks.com/topic/110062-function-to-reorganise-array-keys/#findComment-564781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.