wcc_wtaylor
asked on
Swap < br > with \n based on where PHP is ran
This may not be the proper place to ask this, but in PHP is there a way to swap from < br > to \n depending on where you are running the script? I'd like the < br > to look correctly formatted if running the script on a webpage, but then I want the \n to look correctly when running it in a command prompt.
There is a PHP function called 'nl2br' that will convert newlines '\n' to '<br>'. http://php.net/manual/en/function.nl2br.php
ASKER
I tried that, but it just adds a <br> to the \n so on the command line you still have both.
You have to write code to decide when to use it. There is nothing automatic in PHP that will know how it is being run and make that change for you.
ASKER
Thanks, didn't know if you could program something to see if you were using the command line or if using a webpage. CSS can recognize the browser size to make changes, so didn't know if PHP could do something similar.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.