Jump to content

[SOLVED] file extention from database


The Little Guy

Recommended Posts

I have file names stored in a database, and I was wondering if anyone knew how to get the extension type, basically there will be files like:

song.mp3
file.mp3
cool.jpg
awesome.jpg
sweet.mov
free.see.jpg
my.house.gif
the.song.mp3


and so on, I need to get the extension anyone know how, even if there is more than 1 decimal?
Link to comment
https://forums.phpfreaks.com/topic/30942-solved-file-extention-from-database/
Share on other sites

[quote author=BillyBoB link=topic=118938.msg486474#msg486474 date=1166332536]
hope this helps

[code]
<?php
$query = mysql_query("SELECT * FROM tablename");
$array = mysql_fetch_array($query);
if (in_array("mp3", $array) ) {
  echo("this is a mp3");
}
if (in_array("jpg", $array) ) {
  echo("this is a jpg");
}
?>
[/code]
[/quote]

Well, that simply wont work if there is a file called jpg.gif

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.