Home > Backend Development > PHP Tutorial > 帮小弟我看看用什么函数可以实行下面的结果

帮小弟我看看用什么函数可以实行下面的结果

WBOY
Release: 2016-06-13 12:05:21
Original
856 people have browsed it

帮我看看用什么函数可以实行下面的结果
我要实行的效果是两个字段,判断第一个字段是不是属于第二个字段里
比如
$a="2";
$b=“1,2,6,7,13”;

判断 $b包含$a



再比如
$a="3";
$b=“1,2,6,7,13”;

判断出结果  $b不包含$a
------解决方案--------------------
简单点就(但不严密)
echo strpos($b, $a) !== false ? '在' : '不在';

严密点就
echo in_array($a, explode(',', $b)) ? '在' : '不在';

因提到“字段”,可能是在 mysql 中
find_in_set(a, b)

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