Forum Moderators: coopster
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!