how to check multiple $_POST variable for existence using isset()?

前端 未结 9 857
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 05:17

I need to check if $_POST variables exist using single statement isset.

if (isset$_POST[\'name\']  &&  isset$_POST[\'number\']  &&am         


        
9条回答
  •  旧巷少年郎
    2020-12-18 06:09

    Use simple way with array_diff and array_keys

    $check_array = array('key1', 'key2', 'key3');
    if (!array_diff($check_array, array_keys($_POST)))
        echo 'all exists';
    

提交回复
热议问题