当前位置:   article > 正文

php判断多维数组是否存在字符串,php判断多维数组是否存在某个值_PHP教程

php判断多维数组中字段是否包含某个字符串的值

echo “(1)”;

if (in_array("Irix", $os)) {

echo "Got Irix";

}

if (in_array("mac", $os)) {//in_array() 是区分大小写的

echo "Got mac";

}

$a = array('1.10', 12.4, 1.13);

echo "(2)";

if (in_array('12.4', $a, true)) {//in_array() 严格类型检查

echo "'12.4' found with strict checkn";

}

if (in_array(1.13, $a, true)) {

echo "1.13 found with strict checkn";

}

$a = array(array('p', 'h'), array('p', 'r'), 'o');

echo "(3)";

if (in_array(array('p', 'h'), $a)) {

echo "'ph' was foundn";

}

if (in_array(array('f', 'i'), $a)) {//in_array() 中用数组作为 needle

echo "'fi' was foundn";

}

if (in_array('o', $a)) {

echo "'o' was foundn";

}

?>

程序运行结果是:

(1)Got Irix

(2)1.13 found with strict check

(3)'ph' was found 'o' was found

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/634252
推荐阅读
相关标签
  

闽ICP备14008679号