PHP determines whether a string contains an element value in an array

不言
Release: 2023-03-24 11:34:02
Original
5631 people have browsed it

The content of this article is about PHP's judgment that a string contains an element value in an array. It has a certain reference value. Now I share it with you. Friends in need can refer to it

$arr=array('安卓','过滤','小程序');
//如果是字符串,需要先打散成数组再判断$str='安卓手机';
foreach($arr as $key){
if(strstr($str,$key))
{
//列表中包含过滤的新内容.如果str来自其它网页,需要保证编码相同.
echo  0;
exit;
        }else{    echo  1;
        exit;
    }
    }
Copy after login

Related recommendations:

php method to determine whether the json format is correct


The above is the detailed content of PHP determines whether a string contains an element value in an array. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template