Image Names

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

Image Names

Post by wesnoel »

Story:
Ok I'm reading a csv file and one of the values is a image name, green_dot1.gif.


Question:
Is there a way, once I have read the value, to remove the .gif extension so it becomes green_dot1?


It would be cool if so.

TIA guys and gals!

Wes/
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post by xisle »

sure, use str_replace()
go here for the usage..
http://www.php.net/manual/en/function.str-replace.php
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

Post by wesnoel »

//$var is the image variable

$var=str_replace (".gif", " ", $var);

This take out the extension.

works great!

Thanks xisle!

Wes/
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

The other thing you can do (because it's always nice to have options) is use basename():

Code: Select all

$var = basename($var, '.gif')
Mac
Post Reply