Programming/PHP / / 2022. 5. 2. 11:54

[정규표현식]이미지만 갖고 오기

728x90
<?php
$contents = "<p><img src='http://어쩌고저쩌고/upload/data/test.jpg'></p>";
$pattern = "/<img[^>]*src=[\'\"]?([^>\'\"]+[^>\'\"]+)[\'\"]?[^>]*>/i";
preg_match_all($pattern, $contents, $matchs);
print_r($matchs);

 

반응형