Reply to Re: Testing if an array is empty

Your name:

Reply:


Posted by burgermeister01 on 08/13/07 16:04

On Aug 13, 10:57 am, zzapper <zzap...@gmail.com> wrote:
> On Aug 13, 4:42 pm, "R. Rajesh Jeba Anbiah"
>
> <ng4rrjanb...@rediffmail.com> wrote:
> > On Aug 13, 8:32 pm, zzapper <zzap...@gmail.com> wrote:
>
> > > Hi,
> > > Have tried to google this without 100% satisfaction.
>
> > > A function reads a mysql record into an array and returns it, if it
> > > doesnt exist it returns '' or FALSE.
>
> > > What ways do I have to test that my returned array is not empty
>
> > http://in2.php.net/empty
>
> Hi
> The problem I have with empty() is as follows
>
> <?php
> $fred=array ('');
> if (empty($fred)) { echo "empty";}
> else {echo 'not empty';}
> ?>
>
> reports not empty?
>
> zzapper

This is because the array technically has one element that is equal to
''. To deal with this you will probably either need to clean the array
first, removing any elements that are equal to '', or checking each
element as you process the array and handle the empty ones differently.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация