1

How to add \r\n next to the output: <div>%s ► %s</div>

For ex-

First output
\r\n
Second output

in:

printf("<div>%s ► %s</div>", $r['bla-bla'], $r['bla-bla']);

I have tried like:"<div>%s ► %s</div>\r\n" but it doesn't work.

CodNoob
  • 43
  • 1
  • 8
  • Bear in mind that line breaks have no effect in HTML documents. You may want to use `
    ` instead, jf you're viewing the output in a web page.
    – ADyson Aug 05 '21 at 18:07
  • P.s. if you want the line break _between_ the two outputs (I assume %s denotes an output?) then `
    %s ► %s
    \r\n` doesn't make sense...surely it would need to be `
    %s \r\n %s
    `.
    – ADyson Aug 05 '21 at 18:09
  • The output is something like: 101 ► Description. I want a next line after one such output. – CodNoob Aug 06 '21 at 02:50
  • `div`s are block level elements so if you're viewing the output in a browser it will automatically go to to the next line after each div closes, unless you use CSS to alter it. Or are you viewing the raw output in a console or text editor or something? You didn't really explain the scenario. – ADyson Aug 06 '21 at 15:07

1 Answers1

3

Try PHP_EOL like:

<?php
printf("first line" . PHP_EOL . "SECOND line");

See also When do I use the PHP constant “PHP_EOL”?

Top-Master
  • 7,611
  • 5
  • 39
  • 71