一款实用php 正则文件扩展名代码
发布时间:2022-07-26 10:17:26 所属栏目:PHP教程 来源:互联网
导读:*/ function attachicon($type,$size=) { static $attachicons = array( 0 = common.gif, 1 = image.gif, 2 = binary.gif, 3 = rar.gif, 4 = msoffice.gif, 5 = text.gif, 6 = html.gif, 7 = real.gif, 8 = av.gif, 9 = flash.gif, 10 = pdf.gif, 11 = torre
|
*/ function attachicon($type,$size='') { static $attachicons = array( 0 => 'common.gif', 1 => 'image.gif', 2 => 'binary.gif', 3 => 'rar.gif', 4 => 'msoffice.gif', 5 => 'text.gif', 6 => 'html.gif', 7 => 'real.gif', 8 => 'av.gif', 9 => 'flash.gif', 10 => 'pdf.gif', 11 => 'torrent.gif' ); if(preg_match("/image|^(jpg|gif|png|bmp)/", $type)) { $typeid = 1; } elseif(preg_match("/bittorrent|^torrent/", $type)) { $typeid = 11; } elseif(preg_match("/pdf|^pdf/", $type)) { $typeid = 10; } elseif(preg_match("/flash|^(swf|fla|swi)/", $type)) { $typeid = 9; } elseif(preg_match("/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)/", $type)) { $typeid = 8; } elseif(preg_match("/real|^(rm|rv)/", $type)) { $typeid = 7; } elseif(preg_match("/htm|^(php|js|pl|cgi|asp教程)/", $type)) { $typeid = 6; } elseif(preg_match("/text|^(txt|rtf|wri|chm)/", $type)) { $typeid = 5; } elseif(preg_match("/word|powerpoint|^(doc|ppt)/", $type)) { $typeid = 4; } elseif(preg_match("/compressed|^(zip|arj|rar|arc|cab|lzh|lha|tar|gz)/", $type)) { $typeid = 3; } elseif(preg_match("/octet-stream|^(exe|com|bat|dll)/", $type)) { $typeid = 2; } else { $typeid = 0; } return $size.$attachicons[$typeid]; } (编辑:周口站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
