function data_convert($pattern, $subject)
{
$matches = array();
if (preg_match_all($pattern, $subject, $matches)) {
return $matches[0];
} else {
return null;
}
}
$txtContent = file_get_contents('./match.txt');
$dsName = data_convert('/[\x7f-\xff]+/',$txtContent);
foreach ($dsName as $val){
echo $val."<br>";
}
匹配中文
匹配?前面的数据:
$pattern = '/(http|https):\/\/(.*)\?/';
$dirvalue = 'https://img1.homary.com/mall/222/122/1231231.jpg?sd=1sds&ss=2';
preg_match($pattern,$dirvalue, $arr);
print_r($arr);exit;