note 13584 deleted from function.filetype by philip

From: Date: Mon, 30 Dec 2002 04:09:07 +0000
Subject: note 13584 deleted from function.filetype by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-41447@lists.php.net to get a copy of this message
A function you can change to return any filetype you want: first use philikon@gmx.net's code to give the function the file ext, his code is shown here: function get_file_ext( $filename ) { ereg( ".*\.([a-zA-z0-9]{0,5})$", $filename, $regs ); return( $regs[1] ); } and pass that to this: function get_file_type($f_ext) { $image_exts = array (".jpg", ".gif", ".png"); $text_exts = array (".htm", ".html", ".txt"); $arr_size = sizeof($image_exts); for($gft_count=0;$gft_count<$arr_size;$gft_count++){ if ($image_exts[$gft_count] == $f_ext) { $file_type = "image"; } } $arr_size = sizeof($text_exts); for ($gft_count=0;$gft_count<$arr_size;$gft_count++){ if ($text_exts[$gft_count] == $f_ext) { $file_type = "text"; } } if ($file_type = "") { $file_type = "unknown"; } return( $file_type ); } change the arrays to whatever you're looking for.

« previous php.notes (#41447) next »