dhimok Posted January 24, 2008 Share Posted January 24, 2008 Hey everyone! I have this array as you see and I get 2 extra keys that are not supposed to be there with empty values. How do i ignore them? Array ( [0] => 5 [1] => 6 [2] => [3] => 4 [4] => ) thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/87656-array-issue/ Share on other sites More sharing options...
SirChick Posted January 24, 2008 Share Posted January 24, 2008 Do you mean u don't want row 2 and row 4 to show because they are blank ? Quote Link to comment https://forums.phpfreaks.com/topic/87656-array-issue/#findComment-448341 Share on other sites More sharing options...
dhimok Posted January 24, 2008 Author Share Posted January 24, 2008 Yes, thats right Quote Link to comment https://forums.phpfreaks.com/topic/87656-array-issue/#findComment-448342 Share on other sites More sharing options...
KrisNz Posted January 24, 2008 Share Posted January 24, 2008 array_filter() Quote Link to comment https://forums.phpfreaks.com/topic/87656-array-issue/#findComment-448377 Share on other sites More sharing options...
dhimok Posted January 24, 2008 Author Share Posted January 24, 2008 Well here's the answer to my own question, just if someone needs it: // reorder array foreach($array as $key => $value) { if($value == "") { unset($array[$key]); } } $new_array = array_values($array); Thanks for the viewing anyway Quote Link to comment https://forums.phpfreaks.com/topic/87656-array-issue/#findComment-448378 Share on other sites More sharing options...
Nhoj Posted January 25, 2008 Share Posted January 25, 2008 Could have just done: $newarray = array_filter($array); http://us.php.net/manual/en/function.array-filter.php Quote Link to comment https://forums.phpfreaks.com/topic/87656-array-issue/#findComment-448427 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.