LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-07-2002, 08:04 AM   #1
antken
Member
 
Registered: Nov 2000
Posts: 368

Rep: Reputation: Disabled
picking off file extentions in php


hi,

i have an intranet system written in php it is designed to read folders and display their contents and put a nice little icon at the side of the file for example a m$ word document would get a blue letter W at the side.

unfortunatly the way its written it only picks off a 3 letter extention so .html files dont display
is there a way to read the file name from the right upto the . (dot) and put it into a string?

so if i gave it a file name of blah.foobar it would pick off the extention of foobar

thanks
antken
 
Old 08-07-2002, 12:36 PM   #2
Hans Zarkoff
Member
 
Registered: Apr 2002
Location: Canada
Distribution: Slackware
Posts: 58

Rep: Reputation: 15
How about:

$string="filename.test.php";
$tok=strtok($string,".");
while ($tok)
{
$filetype=$tok;
$tok=strtok(".");
}
echo $filetype;
 
Old 08-07-2002, 02:36 PM   #3
antken
Member
 
Registered: Nov 2000
Posts: 368

Original Poster
Rep: Reputation: Disabled
thats great thank you

can i ask where you got it from?
or did you pull this out of your head??

thanks once again
 
Old 08-14-2002, 03:49 PM   #4
Hans Zarkoff
Member
 
Registered: Apr 2002
Location: Canada
Distribution: Slackware
Posts: 58

Rep: Reputation: 15
Out of my head, however it's all at php.net. Go there and embrace the php goodness.

Richard... er, Hans.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Picking out the right file when ls | greping XST1 Programming 4 02-15-2005 08:32 PM
.sh extentions help! wisdom Linux - General 4 12-20-2004 06:02 PM
Counting matching file extentions variable Fegero Programming 1 11-17-2003 12:34 PM
frontpage 2003 file extentions bwarn Linux - Software 4 11-12-2003 08:00 AM
changing file extentions Seraph Linux - Newbie 3 09-17-2003 02:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration