Home  >  Article  >  Backend Development  >  How to use explode in php to find whether a certain character exists

How to use explode in php to find whether a certain character exists

高洛峰
高洛峰Original
2016-11-30 13:16:271045browse

The code is as follows:

<?php 
if($_MODULE[tg1_tjly]){ 
$tg1_tjly = explode("|",$_MODULE[tg1_tjly]); 
if(count($tg1_tjly)>1){ //重点在这里,统计数组大于1的时候则说明含有1个或以上的间隔符号“|”。 
$tg1_tjly_tit = $tg1_tjly[0]; 
$tg1_tjly_con = $tg1_tjly[1]; 
}else{ 
$tg1_tjly_tit = &#39;推荐理由&#39;; 
$tg1_tjly_con = $_MODULE[tg1_tjly]; 
} 
}else{ 
$tg1_tjly_tit = &#39;输入推荐理由标题&#39;; 
$tg1_tjly_con = &#39;输入推荐理由内容,请输入推荐理由内容,请输入推荐理由内容。&#39;; 
} 
?>


Statement:
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