Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [PHP] Using str_replace on a database value

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #33708
    iMattR
    Member

    EDIT: It’s alright – I got it sorted!

    Hey, y’all.

    I’m currently in work developing a small news system for a client of their’s, and I’ve been getting along well until I came across converting a value fetched from the database, using a while() loop. Basically, I use the while loop to select the content from the database, and then I can print the page. Unfortunately, this is filled with unnecessary code that the reader doesn’t need to see (i.e. ‘nn’).

    So, I attempted to use str_replace(); to replace ‘nn’ with line-breaks… but to no avail. And I’m still pretty much struggling on this, and any help on it would be great.

    Cheers!

    P.S. Here’s a code snippet:














    $pattern = "nn";

    $replacement = "
    ";

    $string = $result;

    print str_replace($pattern, $replacement, $string);

    ?>





Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.