arrays - test object is null in php -
i want test if object null or not, have follwing code
$listcontact = array(); $contact=$ms->search('email','test@live.fr'); var_dump(($contact)); and result if $listcontact not null give follow
object(stdclass)[6] public 'item' => string 'dfdfsd' (length=7) in case it's null , following result
object(stdclass)[6] how can test variable $listcontact exists or not? i've tried is_null , (empty() not work
use function is_null() follows :
is_null($listcontact); the return value :
returns true if var null, false otherwise.
edit
also can use :
if ( !$your_object->count() ){ //null } for more information see answers
try using array_filter()
$emptyarray= array_filter($listcontact); if (!empty($emptyarray)){ } else{ //nothing there }
Comments
Post a Comment