Friday, November 30, 2018

boolen example

If you store only booleans, use this:
$a = array('a'=> true, 'b'=> true, 'c'=>true);
$af = array_filter($a);
if ($af == $a) {
    echo "all true";
}
if (empty($af)) {
    echo "all false";
}
// set default value
$result = false;

foreach ($array as $key => $value) {
    if ($value === true) {
        $result = true;
        break;
    } 
}

// $result is now true if any value was true, otherwise it's false 

No comments:

Post a Comment

form validation

function formsubmit ( ) { var empname = document .getElementById ( 'emp_name' ). value ; var email = document .getElem...