This is something that I could hack together, but I wondered if anyone had a clean solution to my problem. Something that I throw together will not necessarily be very brief or fast!
I have a string like ///hello/world/// . I need to remove only the first and last slashes, none of the others, so I get a line like this //hello/world// .
PHP trim not quite right: executing trim($string, '/') will return hello/world .
It should be noted that there will not necessarily be any slashes at the beginning or end of a line. Here are some examples of what I would like to do with different lines:
///hello/world/// > //hello/world// /hello/world/// > hello/world// hello/world/ > hello/world
Thanks in advance for your help!
string php trim
Rowan Sep 30 '10 at 19:56 2010-09-30 19:56
source share