Bonjour,
J'ai une chaîne html de laquelle je veux retirer une séquence de balises <p><img /></p>. Mon code ne filtre rien du tout.
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <?php define('IMG_TAG', "<p><img src='%s' alt='' style='float:right; max-width:300px; padding:10px; border 1px solid black;' /></p>"); // ... suite du code ... $tmp = "<h3>Un joli titre</h3><p><img src='customs/1/pictures/homeImg.png' alt='' style='float:right; max-width:300px; padding:10px; border 1px solid black;' /></p><p>Un texte abondant</p>"; $pattern = sprintf(IMG_TAG, "."); $pattern = "#(".$pattern.")#i"; $tmp = preg_replace($pattern, '', $tmp); ?>
Partager