Link to home
Start Free TrialLog in
Avatar of DS928
DS928Flag for United States of America

asked on

Adding Backslashes To PHP echo

I have an echo statement that has three results.  I have spaces between each and I would like to add backslashes.  How would I do this?

echo $thecity.'  '.$thearea.'  '.$thecuisine;

Open in new window


Results:
Boston    Back Bay    American(New)

I would like:
Boston  \  Back Bay  \  American(New)

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of kmslogic
kmslogic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DS928

ASKER

Thank you.  I don't know why I didn't try the most simple solution!  Being new to this.  What do you mean by escape a backslash?
The backslash key is used to handle certain escape sequences, for example

echo "\t" yields a tab character.  So with double quoted strings especially you need to escape the escape or put a double backslash when you want to see just one.

In the case of a single quote quoted string you can just put a single backslash or a double backslash and in both cases it will appear as a single backslash when it is output.
Avatar of DS928

ASKER

It's funny.  With everything being so complex that I am doing, finally a simple solution!