|
Posted by Rik on 08/13/07 15:42
On Mon, 13 Aug 2007 17:32:33 +0200, zzapper <zzapper@gmail.com> wrote:
> 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
Something like the following?
<?php
if(empty($array)) echo '$array is empty';
?>
If you want an empty string, false, and an empty array handled seperatel=
y, =
you can use the following:
<?php
if($return=3D=3D=3Dfalse){ //notice the triple '=3D'
echo 'Function returned false';
} else if($return =3D=3D=3D ''){
echo 'Function returned empty string.';
} else if(is_array($return) && empty($return)){
echo 'Function returned empty array.';
} else {
echo 'Function returned:';
var_dump($return);
}
?>
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|