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

Generating $file with out the file extension

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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.

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

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

or you can use explode function...
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 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]
DecoRJ
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sun Dec 29, 2002 6:38 am

Split

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

What about SPLIT function??

i.e.

$arq="picture.jpg";
$split_file=split´('.',$arq);
echo $split_file[0];
foot123
New php-forum User
New php-forum User
 
Posts: 14
Joined: Wed Nov 06, 2002 4:39 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 5 guests

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