0

I'm trying to use preg_replace to remove commented code in some css styling that's coming through php from a database. If it's better to use srt_replace or some other function please let me know how to do it.

I want to delete the commented code in:

/*here is some commented code*/
background: #AAA;
/*here is some commented code*/

My string of the above code is in $spiderman:

$ironman = preg_replace("//*(.*?)/*/Uis","",$spiderman);

How can I get $ironman to be just

background: #AAA;

Thanks for you help.

Ace Thanks
  • 123
  • 1
  • 1
  • 9

1 Answers1

0

Try out the following preg_replace statement with non-greedy flag

   echo $ironman = preg_replace("/\/\*(.*)\*\//Uis","",$spiderman);
Rinsad Ahmed
  • 1,877
  • 1
  • 10
  • 28