Generating $file with out the file extension

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 2
Joined: Wed Nov 13, 2002 8:21 am
Location: under a rock canada

Postby cyrus » Tue Dec 17, 2002 10:26 pm

Could you just use:

$abv = substr($file,0,strlen($file)-4); /*assumes 3 char extension + 1 for period*/

echo $abv;

I'm not quite sure what you're looking for. Maybe this is a little too simplistic.

Maybe it'll do just fine.


Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Wed Dec 18, 2002 2:39 am

or you can use explode function...

New php-forum User
New php-forum User
Posts: 3
Joined: Sun Dec 29, 2002 6:38 am

Postby DecoRJ » Sun Dec 29, 2002 6:45 am

I think the explode function is better.....

Not all the files have a 3-letter extension....... like, for example, script.c 8)

It´s better to use explode, like this.....

list($file) = explode(".", $filename);

And $file will have everything before the "."[/quote]

New php-forum User
New php-forum User
Posts: 14
Joined: Wed Nov 06, 2002 4:39 pm


Postby foot123 » Mon Feb 10, 2003 5:06 am

What about SPLIT function??


echo $split_file[0];

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 12 guests