WordPress.org

Ready to get started?Download WordPress

Forums

How do I make a line break in this PHP code? (7 posts)

  1. Silvetti
    Member
    Posted 9 years ago #

    error

  2. skippy
    Member
    Posted 9 years ago #

    $repl = array('## #'=>'<dt>','##'=>"</dt>\r\n<dd>",'##'=>'</dd>');

    Single quotes don't do any interpolation. Use double-quotes, and the newline / carriage return controls will get interpolated.

  3. Silvetti
    Member
    Posted 9 years ago #

    Great thanks a lot :)

  4. Silvetti
    Member
    Posted 9 years ago #

    Hmmm sorry that didn't work. I have uploaded the code to a text file as I think some of my code encoded.

    http://www.nuveautek.com/example.txt

    Thanks

  5. skippy
    Member
    Posted 9 years ago #

    Yeah, the forum ate my backslash originally. You need to use baclslash-n \n and backslash-r \r.

    I edited my original reply. Sorry about that.

  6. skippy
    Member
    Posted 9 years ago #

    else
    {
    $repl = array('#<li>#'=>'<dt>','#</a>#'=>"</a></dt>\r\n<dd>",'#</li>#'=>'</dd>');
    $output .= "<dl id='linklist' class='linkage'>\r\n" . preg_replace(array_keys($repl), array_values($repl), $ret) . '</dl>';
    }
    return $output;

    You can use the opposite kind of quote mark inside the other without backslash escaping them. So inside of single quotes, you can freely use double-quotes (though the outer single quotes will still suppress interpolation). You can use single quotes inside of doublequotes, and interpolation will still work.

  7. Silvetti
    Member
    Posted 9 years ago #

    Ah sweet, that did the trick.

    Call me Mr. Picky but I like to see code as it was intended :)

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.