|
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.
Navigation:
[Reply to this message]
|