Forum Moderators: coopster

Message Too Old, No Replies

Easy question! (I hope.)

How do I escape a closing curved bracket: ')'

         

ronin

10:29 pm on Dec 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi, I'm a bit new to PHP but I've made a resolution to start learning!

I am writing a basic script to manipulate a string.

The script isolates a part of the string and turns it into a new string. If that new string has certain characters on the end, I want to snip these off.

Here's an example involving a period which needs to be snipped off.


if($last_character == "."){$shortname = substr($shortname, 0, -1);}

So far, so good!

Another character I want to snip off is the closing curved bracket:

)

However, when I duplicate the code above, swapping in the bracket for the period, it doesn't work - presumably because the closing bracket is messing up the PHP syntax.

I have alternatively tried

\)

and

)

but neither of these seem to work either.

What should I be using to escape the ')' ?

Many thanks in advance!

ronin

11:09 pm on Dec 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hahaha. I'm an idiot >;->

All sorted - the error was something else entirely and the closing bracket in ")" didn't even need to be escaped it turns out.

Don't you just love learning something completely new? >;->

Thanks, as ever, (sincerely!) for being there, guys.

dreamcatcher

12:56 am on Dec 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you sorted it ronin. :)

dc