Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing a null/empty/zero values from an array

Status
Not open for further replies.

jimoblak

Instructor
Joined
Oct 23, 2001
Messages
3,620
Location
US
How can I remove null/empty/zero values from an array?

I seem to have some empty values that are taking up positions in an array. I don't like them. They annoy me.

I'm also confused because there are sometimes 2 or 3 empty positions even after I apply array_unique()



- - picklefish - -

Why is everyone in this forum responding to me as picklefish?
 
Keep in mind that array_unique() removes duplicate values from your array, so only use it if that's your intension!

Clearing empty values... Couldn't find a PHP function for that (quite sure that one exists, though), but you could loop through the array and test it with

if(!$myArray[index])

Good luck §;O)


Jakob
 
Unique array elements was my intention.

I ended up making a conditional print statement if a real value existed in the array position.

Thanks

- - picklefish - -

Why is everyone in this forum responding to me as picklefish?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top