字符串截取:
if ($keyword_str!=''){
echo substr($keyword_str,0,-1);//去掉最后一位
}
判断指定字符串是否存在:
if (strpos($dh_url,"/jingyan")!==false){
$class_2='class="dh_focus"';//存在时的处理
}
判断是否为数字及Input格式化为数字:
if (!is_numeric($id)){
echo "No num";
exit;
}
字符串长度:
$str = ‘aaaaaa';
if(strlen($str) > 6){
echo "字符串大于6";
}
通过数组判断字符串是否在多个字符串中匹配
$people = array("Bill", "Steve", "Mark", "David");
if (in_array("Mark", $people)){
echo "匹配已找到";
}else{
echo "匹配未找到";
}
?>
替换多个空格为一个
$jieguo = preg_replace("/(s+)/",' ',$jieguo);
未经允许不得转载:任鹏个人博客 » 字符串截取、长度、类型判断等
最新评论
Forex wiki. https://lt.forex-stock-bitcoin-brokers.com
Magnificent items from you, man. I have take note your stuff
Following on from the 3rd March Meetings held by economic de
It is remarkable, rather valuable message dfgdlfg2131.32
一般都会有一个沙盒期的,过了沙盒期就会慢慢放出来
百度不收录是应为是新站的原因吗?
The spike in consumer prices that left inflation at a four-d