How To Check If Array Is Empty Or False Value
RegisterLogin
How To Check If Array Is Empty Or False Value
Post Description: How To Check If Array Is Empty Or False Value
Tags: How, To, Check, If, Array, Is, Empty, Or, False, Value
This Post Was Posted On Feb 29, 2008 By php help #1311
Post Description: How To Check If Array Is Empty Or False Value
Tags: How, To, Check, If, Array, Is, Empty, Or, False, Value
This Post Was Posted On Feb 29, 2008 By php help #1311
How To Check If Array Is Empty Or False Value by php help
<?php
$myarray= array();
$myarray[0] = "";
$myarray[1] = false;
if($myarray){
echo "this is true";
}else{
echo "this is false";
}
?>
$myarray= array();
$myarray[0] = "";
$myarray[1] = false;
if($myarray){
echo "this is true";
}else{
echo "this is false";
}
?>
but when i run it, it still comes out true?
when i do this:
PHPCODE:
print_r(array_values($myarray));
it shows me this: Array ( [0] => )
how can i check or verify that an array has a value of zero or false then?
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
hostman
#1742 1
you can do two things:
OPTION 1: USE ISSET() FUNCTION
<?php
$myarray= array();
$myarray[0] = "";
$myarray[1] = false;
if(isset($myarray)){
echo "this is true";
}else{
echo "this is false";
}
?>
$myarray= array();
$myarray[0] = "";
$myarray[1] = false;
if(isset($myarray)){
echo "this is true";
}else{
echo "this is false";
}
?>
OPTION 2: USE EMPTY() FUNCTION
<?php
$myarray= array();
$myarray[0] = "";
$myarray[1] = false;
if(empty($myarray)){
echo "this is true";
}else{
echo "this is false";
}
?>
$myarray= array();
$myarray[0] = "";
$myarray[1] = false;
if(empty($myarray)){
echo "this is true";
}else{
echo "this is false";
}
?>
Feb 25, 2008 Reply Report abuse
©2011 Webune Forums - Fri Dec 30, 2011 2:23 am
Powered by: Webune Forums V3
Powered by: Webune Forums V3