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.
wcc_wtaylorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
There is a PHP function called 'nl2br' that will convert newlines '\n' to '<br>'.  http://php.net/manual/en/function.nl2br.php
0
wcc_wtaylorAuthor Commented:
I tried that, but it just adds a <br> to the \n so on the command line you still have both.
0
Dave BaldwinFixer of ProblemsCommented:
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.
0
wcc_wtaylorAuthor Commented:
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.
0
Dave BaldwinFixer of ProblemsCommented:
You might be able to write code that does it but there is nothing built into PHP that will do it for you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.