Linked Questions

Popular Questions

How to replace text in html tag?

Asked by At

I have a string

$text =<<<HTML
<div align="center"><center><img src='http://ecx.images-amazon.com/images/I/41KZa6thzcL._SS500_.jpg' alt="The Birthday of the World: And Other Stories"/></center><br/>
thanks all "coder". </div>

HTML;

I want to replace all " from tag with \" or ' with \' and don't replace if " or ' not in tag

so result is

  $text =<<<HTML
    <div align=\"center\"><center><img src=\'http://ecx.images-amazon.com/images/I/41KZa6thzcL._SS500_.jpg\' alt=\"The Birthday of the World: And Other Stories\"/></center><br/>
     thanks all "coder".
    </div>
       HTML;

Please help me . Great Thanks

Related Questions