字符串截取:
if
(
$keyword_str
!=
''
){
echo
substr
,0,-1);
//去掉最后一位
}
判断指定字符串是否存在:
strpos
$dh_url
,
"/jingyan"
)!==false){
$class_2
=
'class="dh_focus"'
;
//存在时的处理
判断是否为数字及Input格式化为数字:
if (!is_numeric($id)){
echo "No num";
exit;
<
input
name
"px"
type
"text"
value
""
onKeyUp
"this.value=this.value.replace(/D/g,'');"
onafterpaste
"this.value=this.value.replace(/D/g,'')"
/>
字符串长度:
$str
= ‘aaaaaa';
strlen
) > 6){
"字符串大于6"
通过数组判断字符串是否在多个字符串中匹配
<?php
$people
array
"Bill"
"Steve"
"Mark"
"David"
);
(in_array(
))
{
"匹配已找到"
else
"匹配未找到"
?>
替换多个空格为一个
$jieguo
= preg_replace(
"/(s+)/"
' '