php - regex to match p tags and add br's inside of them -


Well the title of the question explains the question: D but here is an example

  Asdf asdf & lt; P & asd; Asdf asdf asdf & lt; / P & gt;  

How much do I have to get it to apply regex and nl2br inside the P tag so that the output will be:

  asdf asdf & lt; P & gt; Asdf & lt; Br / & gt; Asdf & lt; Br / & gt; Asdf & lt; / P & gt;  

Edit: In PHP,

use instead of regex

  $ html = str_get_html (...); Foreach ($ html- & gt; Find ('P') as $ element) {// p $ ihtml = p-> Innertext; // apply $ ihtml = nl2br ($ ihtml); // save $ p- & gt; Innertext = $ ihtml; } // Print new output $ html;  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -