Preg_replace

7 posts by 3 authors in: Forums > CMS Builder
Last Post: September 24, 2013   (RSS)

By design9 - September 20, 2013

I am trying to replace </p> with <br /> in specific content. I am using the following code :

<?php echo preg_replace('</p>', '<br />', $articlesRecord['content']); ?>

It works in that is puts the correct spacing in but adds the < > into the content. See attached screenshot.

Can you help me figure what I am missing or doing wrong?

Thanks!

April

Attachments:

contenttags.jpg 641K

By jenolan - September 20, 2013

My suggestion ;-)

<?php echo string_ireplace( '</p>', '<br />', $articlesRecord['content']); ?>

---
<?= "Jenolan(Larry) :: Coding Since 1973" ?>
Peace and Long Life

By design9 - September 23, 2013

Sorry, that doesn't work, that gives me an error on page.

By jenolan - September 23, 2013

That should work you need to show a before and after to give me a little bit if a hint.

---
<?= "Jenolan(Larry) :: Coding Since 1973" ?>
Peace and Long Life

By design9 - September 24, 2013

Here is the error I get:

Fatal error: Call to undefined function string_ireplace() in C:\inetpub\carolinaparent\newarticlemain.php on line 234

My page is attached.

Thanks so much!

Attachments:

newarticlemain.php 19K

By design9 - September 24, 2013

Thanks Jason!

That is perfect, exactly what I needed!

April