Page 1 of 1

string manipulation help

Posted: Wed Jul 02, 2008 6:34 am
by jake2891
Hi guys,

Im trying to search a string for the last forwardslash and remove everything after and including the forward slash.

for example my string '/ggfx/modify/89/97/bee.jpeg/121498954583267'

i want to be left with /ggfx/modify/89/97/bee.jpeg

any help will be greatly appreciated.

Re: string manipulation help

Posted: Wed Jul 02, 2008 7:46 am
by Bill H
see strrpos() and substr()

Re: string manipulation help

Posted: Wed Jul 02, 2008 7:48 am
by jaoudestudios
Step1
use strrpos to find the position of the character within your string.

Step 2
use substr to chop the bit you want out

Re: string manipulation help

Posted: Wed Jul 02, 2008 7:48 am
by jaoudestudios
ah Bill beat me to it :D

Re: string manipulation help

Posted: Wed Jul 02, 2008 8:10 am
by highjo
you can use strripos too
look here http://www.php.net/manual/en/function.strripos.php