在PHP中提取字符串中第一個(gè)數(shù)字?
測(cè)試過(guò),符合要求
$str="登山服:5620A登山服";
$search1 = implode("-",range("a","z"));
$search2 = implode("-",range("A","Z"));
$search3 = implode("-",range(0,9));
$search4 = implode("-",array(":"));
$search = $search1."-" .$search2."-" .$search3."-" .$search4;
$oldarr = explode("-",$search);
$newarr = array();
foreach($oldarr as $value)
$newarr [] = "{mysplit}";
$str = str_replace($oldarr, $newarr, $str);
$arr = explode("{mysplit}",$str);
echo $arr[0];