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.
string manipulation help
Moderator: General Moderators
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: string manipulation help
see strrpos() and substr()
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: string manipulation help
Step1
use strrpos to find the position of the character within your string.
Step 2
use substr to chop the bit you want out
use strrpos to find the position of the character within your string.
Step 2
use substr to chop the bit you want out
Last edited by jaoudestudios on Wed Jul 02, 2008 7:49 am, edited 1 time in total.
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: string manipulation help
ah Bill beat me to it 
Re: string manipulation help
you can use strripos too
look here http://www.php.net/manual/en/function.strripos.php
look here http://www.php.net/manual/en/function.strripos.php