美文网首页
isset用法

isset用法

作者: Alex80 | 来源:发表于2020-07-27 15:11 被阅读0次

    $matches = [1,2,3];

    $k = array_search(0,$matches);

    if(isset($k)){

        unset($matches[$k]);

    }

    var_dump($matches);​

    返回array(2) {

    [1]=>

    int(2)

    [2]=>

    int(3)

    }

    isset-----null 或未定义的变量才为false,isset(false)返回true

    另外unset($matches[false])会去掉k为0的数组

    isset判断用是否!==false

    相关文章

      网友评论

          本文标题:isset用法

          本文链接:https://www.haomeiwen.com/subject/rsmzlktx.html