function delete_img($content){
$img_path =
"/<img.*src=\"([^\"]+)\"/U";
$matches =
array();
preg_match_all(
$img_path,
$content,
$matches);
foreach(
$matches[
1]
as $img_url){
if(strpos(
$img_url,
'emoticons')===
false){
$host =
'http://' .
$_SERVER[
'HTTP_HOST'] .
'/';
$filepath = str_replace(
$host,
'',
$img_url);
if(
$filepath ==
$img_url)
$filepath = substr(
$img_url,
1);
@unlink(
$filepath);
$filedir = dirname(
$filepath);
$files = scandir(
$filedir);
if(count(
$files)<=
2)@rmdir(
$filedir);
}
}
unset(
$matches);
}
转载请注明原文地址: https://www.6miu.com/read-56863.html