php正则表达式之正则字符中的图片地址 |
时间:2015-01-23 来源:西部数据 作者:西部数据 |
|
- if (preg_match_all("/http://[^ "']+[.jpg|.gif|.jpeg|.png]+/ui",stripcslashes($content),$aliurl)){
- $i=0;
- while(list($key ,$v) = each($aliurl[0])){
-
- $filetype = pathinfo($v, PATHINFO_EXTENSION);
- $ff = @file_get_contents($v);
- if(!stripos($v,"lao8.org")){
- if (!emptyempty($ff)){
- $dir = "upload/".date("Ymd")."/";
- if (!file_exists($dir)){
- @mkdir($dir,511,true);
- }
- $nfn = $dir.date("Ymdhis").$i.".".$filetype;
- $nf = @fopen($nfn,"w");
- fwrite($nf,$ff);
- fclose($nf);
- $i++;
- echo "<img src="".$nfn."">";
- $content = str_replace($v,$nfn, $content);
- }else{
- $content = str_replace($v,http:
- }
- }
- }
- }
|
|
|
|