Mladen Milankovic wrote:
>
>
> On 5/6/08, lilmouseman <[EMAIL PROTECTED]
> <mailto:lilmouseman%40yahoo.com>> wrote:
> >
> > Hi Everyone. First time poster.
> >
> > My question is about extracting part of a path from the right.
> >
> > e.g. folder/images/testimage.jpg
> >
> > how do I get everything from the right all the way up to the first "/"
> >
> > Thank you in advance.
> >
>
> Hi and welcome.
> Try something like this:
> $path = 'folder/images/testimage.jpg';
> substr($path, strpos($path, '/'));
>
> This will give you: /images/testimage.jpg
>
> If you don't need the first / :
> substr($path, strpos($path, '/')+1);
> This will give: images/testimage.jpg
>
> regards
> mmlado
>
I would do this instead, it would assure you that you are in fact
getting everything to the right of the last '/':
$path = '/folder/images/testimage.jpg';
preg_match("#.+/(.+)$#",$path,$image);
$image[1] will have the capture of "testimage.jpg".
Billy P.