WordPress.org

Support

Support » Plugins and Hacks » How do I make a line break in this PHP code?

How do I make a line break in this PHP code?

Viewing 6 replies - 1 through 6 (of 6 total)
  • $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.

    Great thanks a lot 🙂

    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

    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.

    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.

    Ah sweet, that did the trick.

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

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How do I make a line break in this PHP code?’ is closed to new replies.
Skip to toolbar