关于PHP正则有关问题

WBOY
Release: 2016-06-13 11:23:14
Original
790 people have browsed it

关于PHP正则问题
$lid=str_replace("\r\n","",$lid);

如果$lid获得多个下面该怎么写?请高手帮一下 谢谢

if ($lid==intval($row['id'])) {

}else {
?>


------解决方案--------------------
如果获得多个$lid,则先把$lid explode成为数组,然后循环数组,逐渐去比对:
code:

$lid=str_replace("\r\n","",$lid);

//假设多个id是','号隔开的
//把$lid组合成为数组
$lid_arr =explode(',',$lid);
if(!empty($lid_arr)){
//循环数组
foreach($lid_arr as $lid ){
//原来的比对流程
if ($lid==intval($row['id'])) {

}else {
?>
 

}
}  

------解决方案--------------------
$arr =explode(',',$lid);
if (in_array(intval($row['id']) , $arr) {

}else {
?>
 
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