DS928
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?
Results:
Boston Back Bay American(New)
I would like:
Boston \ Back Bay \ American(New)
Thank you.
echo $thecity.' '.$thearea.' '.$thecuisine;
Results:
Boston Back Bay American(New)
I would like:
Boston \ Back Bay \ American(New)
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
It's funny. With everything being so complex that I am doing, finally a simple solution!
ASKER