Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Jan 2011
    Thanked 2 Times in 2 Posts

    Outputting row and replacing line breaks

    Hi, I'm having problems with just 1 thing. It should be simple, but for some reason, I can't seem to make it work.

    So I'm trying to do multiple things. I'm trying to pull the row from the database, then replace any bad words with blanks and then make an array replacing any <? or ?> with the characters &lt;? and ?&gt; so if people do actually have it in the row, then replace it with those characters. Then BBCODE the output of that array and last, if the row still has actual line breaks, then replace it with HTML breaks.

    This is what I have so far, but it only goes up to the BBCODE and it doesn't replace the line breaks with HTML breaks.


    An example for this was yesterday.
    Now it's suppose to be today.
    My intention was to have something like this being outputted after all the replacements.

    An example for this was yesterday. <br /><br /> Now it's suppose to be today.
    HERE is my code:
    PHP Code:
    // function to call and replace the bad word
    function edit_words($STRING,$bannedwords) {
    $bannedwords as $key => $v) {
    $STRING eregi_replace($v,"",$STRING);

    // including the file that has all the bad words in it.

    // $message is already called for in the headers.
    // The code for it was $message = $row['message'];
    $mg "$message";

    // Replacing any <? or ? > in the code
    $array = array('<?' => '&lt;?''?>' => '?&gt;''"' => '\"''\\"' => '\"''\'' => ''');

    $tdsar = strtr($mg, $array);

    $uneditedString = $tdsar;
    $edited = edit_words($uneditedString,$wordz);

    // BBCODING the output
    $bbcode_it = bbcodeHtml($edited);

    // Trying to replace any line breaks in the database
    $array_string = trim(preg_replace('
    /s+/', ' $bbcode_it));

    // Echoing the entire output
    echo $array_string;
    Last edited by xiong_ster123; 09-08-2013 at 05:24 AM. Reason: Resolved


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts