Skip to content

Instantly share code, notes, and snippets.

@davidchc
Created March 19, 2018 12:35
Show Gist options
  • Save davidchc/fc35ae989346ea6e430924319026bd56 to your computer and use it in GitHub Desktop.
Save davidchc/fc35ae989346ea6e430924319026bd56 to your computer and use it in GitHub Desktop.
<?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('/src="([^"]*)"/mis',$content, $matches);
echo '<pre>';
$srcs = $matches[1];
$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