영원한사랑

$pattern ='/(src=|href=)(\'|\")?([^<>\s\'\"]*)(\'|\"|\s|)/i';

preg_match_all( $pattern, $subject, $matches );

print_r($matches[3])


$str = HTML 내용
$url = HTML의 url;

function get_link_files($url,$str){
 $url_arr = parse_url($url);
 $domain = $url_arr['scheme'].'://'.$url_arr['host'];
 if($url{strlen($url)-1}!='/'){
   $path = $domain.$url_arr['path'];
 }
 else{ $path = $url; }
 $pattern ='/(src=|href=)(\'|\")?([^<>\s\'\"]*)(\'|\"|\s|)/i';
 $subject =&$str;
 $matches = array();
 preg_match_all( $pattern, $subject, $matches );

 $r_arr = array();
 $r = $matches[3];
 $r2 = array();
 unset($matches);//삭제
 for($i =0,$m=count($r);$i<$m;$i++){ //경로 재계산
  if($r[$i]{0}=='/'){
   $r2[] = $domain.$r[$i];
  }else if($r[$i]{1}=='/'){
   $r2[] = $path.$r[$i];
  }else if(strpos($r[$i],'http://')===0){
   $r2[] = $r[$i];
  }
 }

 print_r($r2);
 
}