dimanche 28 juin 2015

php remove all attributes from a tag

Here is my code:

$content2= preg_replace("/<([a-z][a-z0-9]*)[^>]*?(\/?)>/i",'<$1$2>', $content1);

This code removes all attributes from all tags in my website, but what I want is to only remove attributes from the form tag. This is what I have tried:

$content2 = preg_replace("/<form([a-z][a-z0-9]*)[^>]*?(\/?)>/i",'<$1$2>', $content1); 

and

$content2 = preg_replace("/<(form[a-z][a-z0-9]*)[^>]*?(\/?)>/i",'<$1$2>', $content1); 

Aucun commentaire:

Enregistrer un commentaire