Jump to content

How can i check if associate array element is empty or not?


colap

Recommended Posts

    Array
    (
        [Comment] => Array
            (
                [post_id] => 1
                [name] => cc
                [email] =>
                [body] => spam
            )     
    )

 

How can i check if email is empty or not? Is there any php built in function? Should i use foreach?

let's check this for example

 

if the variable assign to this value

 

0 ----> number 0
"0"   ----> string 0
"" ----> empty string
"  "  ----> string with whitespace
0.0 ----> double value
array()  ----> empty array
NULL   ----> null value
FALSE -----> boolean false

 

if use

empty() ----> will return TRUE

is_null() ---> return TRUE on NULL value

isset() --->  all above are TRUE except FALSE and NULL value

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.