views:

19

answers:

3

I have a php script that i run via command line like

php file.php

and in that file i have a print statement like

print "<br>Saved the url: {$url} to :{$destination}";

I assumed the br would formant it 1 below the other but when i run the script i get this format which is really hard to read

<br>Saved the url: http://example.com/a.mp3 to :/usr/recordings/3e/1555141317-2349577.mp3<br>Saved the url: http://example.com/b.mp3 to :/usr/recordings

so the formatting is really hard to read in the console. Is there a way to restructure my print to have the output like this

Saved the url: http://example.com/a.mp3 to :/usr/recordings/3e/1555141317-dadfdasffa.mp3
Saved the url: http://example.com/b.mp3 to :/usr/recordings/3c/1555141317-fddfd.mp3
Saved the url: http://example.com/c.mp3 to :/usr/recordings/3f/1555141317-ffdfd.mp3
A: 
print "Saved the url: {$url} to :{$destination}\n";
Aman Kumar Jain
A: 

Have you tried \n\r or \n ?
is for html. Console is different.

Iznogood
+5  A: 

Use a newline instead of br.

print "\nSaved the url: {$url} to :{$destination}";

If you want that to work with html output as well you can check which sapi you're running with:

echo PHP_SAPI == 'cli' ? PHP_EOL : '<br>', "Saved the url: {$url} to :{$destination}";
Raoul Duke
now just replace `\n` for `PHP_EOL` and I upvote
Gordon
hehe. satisfied? :)
Raoul Duke
you can always do both if you don't mind the BRs in your output- `<br/>\n`
Jenni