Checking if all the array items are empty PHP -


i'm adding array of items form , if of them empty, want perform validation , add error string. have:

$array = array(     'requestid'       => '$_post["requestid"]',     'clientname'      => '$_post["clientname"]',     'username'        => '$_post["username"]',     'requestassignee' => '$_post["requestassignee"]',     'status'          => '$_post["status"]',     'priority'        => '$_post["priority"]' ); 

and if of array elements empty perform:

$error_str .= '<li>please enter value @ least 1 of fields regarding request searching for.</li>'; 

you can use built in array_filter

if no callback supplied, entries of input equal false (see converting boolean) removed.

so can in 1 simple line.

if(!array_filter($array)) {     echo '<li>please enter value @ least 1 of fields regarding request searching for.</li>'; } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -