Created
March 19, 2018 12:52
-
-
Save davidchc/63e28fe9a9bb12f22fb64b337a7d8a5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$content = 'jbajdbfkjsd <img src="endereco/imagem1.jpg" /> | |
<img src="endereco/imagem2.jpg" /> | |
<img src="endereco/imagem3.jpg" /> | |
<img src="endereco/imagem4.jpg"/> | |
'; | |
preg_match_all('/<img[^>]*>/i',$content, $matches); | |
$srcs = array_map(function($image){ | |
preg_match('/src="([^"]*)"/mis',$image, $matches); | |
return $matches[1]; | |
}, $matches[0]); | |
$newContent = preg_replace('/<img[^>]*>/i', '', $content); | |
echo $newContent; | |
echo '<hr/>'; | |
echo '<pre>'; | |
print_r($srcs); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment