Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

delete extension from filename

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Postby Flood » Fri Jun 27, 2003 3:53 am

Hi!

When you do the test to know whether it is a .jpg file or not, you use the function substr...
substr returns a string but does not alter the string you pass as an argument.
In other words, calling substr($nomfichier, -3) will not change anything in the variable $nomfichier... And when you use it later, you will therefore still have the full name with the extension...

To solve the problem, try like this
Code: Select all
$fichiers .= ",".substr($nomfichier, 0, strlen($nomfichier) - 4); // I guess you do not want the dot either...


There is another thing, you should perhaps be sure that the file you are currently processing is not a directory with the function is_dir...

/Flood
Flood
New php-forum User
New php-forum User
 
Posts: 23
Joined: Tue Jun 24, 2003 4:49 am

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron