[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to trim a string to leave only the image name

Posted on 2003-10-24
7
Medium Priority
?
213 Views
Last Modified: 2006-11-17
I am parsing the following string from a previous page using POST .

folder/subfolder/images/imagename.jpg

to create a link to the image.

I also need to display on the page only the imagename.

How can I remove everything before the imagename and the .jpg file extention?
0
Comment
Question by:coddie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
shmert earned 200 total points
ID: 9618149
Use basename($path) to get the last path component.
0
 

Author Comment

by:coddie
ID: 9618172
Hi shmert,
Thanks for a prompt reply.
sorry I am a newbie to PHP I dont understand comment, can you expand a little more.
0
 

Author Comment

by:coddie
ID: 9618222
Sorted ......
Thanks for the pointer shmert, It works a treat, the points are yours, one more quick related question - some image names have a 2 word title,ie "so big.jpg" this returns as "so%20big" how can I remove the %20 ?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:coddie
ID: 9618286
Ok .... solved it, I had left the %20 in the parsed URL from the previous page. doh !! ;-)

All works as I want, many thanks shmert

here's 50 points.
0
 
LVL 11

Expert Comment

by:shmert
ID: 9621666
Thanks, coddie.  You may also be interested in urlencode() and urldecode() respectively, for encoding spaces and special characters for urls.

Cheers,
Sam
0
 

Author Comment

by:coddie
ID: 9622050
Cheers Sam,
Thanks for the advice, since my first enquiry and your reply, I have got 'right into' what one can do with strings ..... !

As a ASP coder, I didn't realise there were so many operations that one could perform on a string in PHP.

Learn something new everyday.

All the best

Coddie
0
 
LVL 11

Expert Comment

by:shmert
ID: 9627554
Yes, it seems there are almost too many sometimes.  My biggest gripe is that the arguments to all the string operators aren't always consistent.  Check the manual regularly :-)
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question