1. date('G',time()) 整点. echo(strtotime("3 October 2011")); 时间
2. strpos 查找字符串首次出现的位置 方法 (用于获取你指定的字符串集)
public function findneed($wholestr,$strkey1,$strkey2)
{
$num1 = strpos($wholestr , $strkey1)+strlen($strkey1);
$num2 = strpos($wholestr ,$strkey2);
$needstr =substr($wholestr ,$num1,$num2-$num1 );
return $needstr;
}
例子:findneed($fax2,'址:','邮')
3.ord 返回 第一个字符的吧AscII值
Ord(substr($str,$i,1)>=0x80)
Chr(返回指定的字符串)
4.Substr 截取字符串
$rest = substr("abcdef", 2, -1); // 返回"cde"
2 表示 从开头获取 正数-1表示从结尾 去掉几个数
$rest = substr("abcdef", -3, -1); // 返回"de" -3 表示从结尾获取几个数-1同上
5.preg_replace 执行正则 搜索 替换
preg_replace('/\s/','',$name) =》替换为空
同:str_replace(':','',$code)6. strripos 字符串最后一次出现的位置
$pos1 = strripos($explode[$i],'=');
7. htmlspecialchars 网页以字符串形式返回
8. Explode 分割字符串 返回数组
$explode= explode('加入对比',$name);
9.Rtrim 删除 字符串中的指定字符串
例子: $explode[$i] = rtrim($explode[$i],"num
11.获取网页手机号(包含正则表达式)
function GetPhoneFromInfo($singlestr){
global $PhArea,$db,$citys,$areas,$info;//得到所有的电话号码信息
//if(preg_match_all('(^(\d{3,4}-)?\d{7,8})$|(13[0-9]{9}) ', $singlestr, $matches))
//取手机号
if(preg_match_all('/1[34568][0-9]{9}[^\d]/U', $singlestr, $matches))
{
//print_r($matches);
foreach ($matches[0] as $phonenum)
//$phonenum = str_replace(",", "",$phonenum);
// echo "
".$phonenum;
if (strlen($phonenum)>10) {
$phonenum=substr($phonenum, 0, 11);
$info[mobile] = $mobile=$phonenum; //echo "手机". $mobile;
$singlestr = str_replace($info[mobile], "", $singlestr);
}
}
return $info[mobile];
//return $info[mobile];
}