使用正则匹配的方法获取一些特殊符号,在匹配 $ 符的时候总是取不出来,这里转义了两次才取出来
function getCodeImg($title='')
{
$max_percent = "";
$max_dollar = "";
$dollar = "";
$percent = preg_match("/d+%/", $title,$max_percent);
$money = ['\$','£'];
foreach ($money as $key => $va) {
$dollar = preg_match("/".$va."d+/", $title,$max_dollar);
if($dollar){
break;
}
}
if($percent){
$CodeImg = $max_percent[0];
}else if($dollar){
$CodeImg = $max_dollar[0];
}else{
$CodeImg = "";
}
return $CodeImg;
}