-1

Im not sure what to look for to try to achieve this but I was trying to do a str_replace to all the <p> tags and replace them with <br/> and it worked but then I releaized I need to wrap the content with <p>

this is the code i used

<?php
      $nodecontent = render($content);
      $newcontent = preg_replace("/<p[^>]*?>/", "", $nodecontent);
      $newcontent = str_replace("</p>", "<br /><br />", $newcontent);
  print render($newcontent);
?>

this is what my my content had before

  <div property="content:encoded" class="field-item even">
<p>SOME TExT HERE and here and Here..<p>SOME TExT HERE</p> and here and <p>Here..SOME TExT HERE and here and Here..</p>
</p>
</div>

then after I put the code in it looks like this so it did work to some degree but stripped the <p> tag

    <div property="content:encoded" class="field-item even">
SOME TExT HERE and here and Here..<br/><br/>SOME TExT HERE<br/><br/> and here and <br/><br/>Here..SOME TExT HERE and here and Here..<br/><br/>
</div>

but i want it to look like this without stripping the <p> tag as a wrapper

   <div property="content:encoded" class="field-item even"><p>
        SOME TExT HERE and here and Here..<br/><br/>SOME TExT HERE<br/><br/> and here and <br/><br/>Here..SOME TExT HERE and here and Here..<br/><br/>
        </p></div>
user874185
  • 813
  • 2
  • 9
  • 15
  • 2
    Cannot resist... http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – EboMike Sep 14 '11 at 23:47
  • -_- well thats why im here for guidance, and i get down voted, my code worked partially... – user874185 Sep 14 '11 at 23:56
  • and your link doesnt even help... – user874185 Sep 14 '11 at 23:58
  • Behavior like this is why we get pages like this: http://www.google.com/#sclient=psy-ab&hl=en&source=hp&q=stackoverflow+sucks&pbx=1&oq=stackoverflow+sucks&aq=f&aqi=&aql=&gs_sm=e&gs_upl=1931l7078l0l7604l15l15l0l2l2l0l393l2502l0.8.4.1l13l0&bav=on.2,or.r_gc.r_pw.&fp=f51f088013f93507&biw=1024&bih=531 – Herbert Sep 15 '11 at 00:12
  • What does **render** do in `$nodecontent = render($content);` – Herbert Sep 15 '11 at 01:24
  • it echos out the content – user874185 Sep 15 '11 at 19:46

1 Answers1

0

between jquery and php i figured this out, not thanks to the others who criticized me and down voted me.

    <script type="text/javascript" >
    jQuery(document).ready(function() {
        jQuery(".field-item").wrapInner('<p></p>')
    });
    </script>

    <?php $nodecontent = render($content);
      $newcontent = preg_replace("/<p[^>]*?>/", "", $nodecontent);
      $newcontent = str_replace("</p>", "<br /><br />", $newcontent);

 print render($newcontent); ?>
user874185
  • 813
  • 2
  • 9
  • 15