Forum Moderators: coopster

Message Too Old, No Replies

Help Escaping backslash

         

BlackRaven

12:35 am on Apr 16, 2007 (gmt 0)

10+ Year Member



How would one go about escaping a slash that is in an arrary?

$test_char=array('<', '#', '%', '\', '/', ';', '&');

[edited by: BlackRaven at 12:36 am (utc) on April 16, 2007]

cameraman

12:59 am on Apr 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In single quotes like you have it you don't need to, but inside double quotes it's:
"\\"

BlackRaven

3:06 am on Apr 16, 2007 (gmt 0)

10+ Year Member



cameraman is something wrong with this array? For some reason it doesn't work...

$array_bad_chars=array('<', '#', '%', '\', ';', '&', '¼', '/');

[edited by: BlackRaven at 3:06 am (utc) on April 16, 2007]

eelixduppy

4:35 am on Apr 16, 2007 (gmt 0)



Try something like this:

$array_bad_chars=array('<', '#', '%', '\\', ';', '&', '¼', '/');
#notice how I've escaped the slash(\)

Also, if you are getting any errors, that would be helpful as well :)

cameraman

5:43 am on Apr 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oops. I apologize for leading you astray - I was thinking about control characters:
echo '\n';
as opposed to
echo "\n";