Removing EMPTY or BLANK entries from an array?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Deseree
Forum Commoner
Posts: 84
Joined: Mon Feb 13, 2006 11:35 pm

Removing EMPTY or BLANK entries from an array?

Post by Deseree »

Hi,
What would you guys advise for removing empty entries in an array, and rekeying, but not resorting at all.

array_unique works to some extent but there is still ONE empty entry and it's just on my nerves...
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Loop through the array and test the value with empty(), use array_splice() to splice out entries one at a time
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

array_filter($array,'strlen') or array_filter($array) depending on what you are actually after.
Post Reply