看板 PHP 關於我們 聯絡資訊
※ 引述《hirabbitt (兔子)》之銘言: : 我用 : substr($p1["name"],strlen($p1["name"])-3) : 去寫 : 一般是可以用 : 但某些檔案的副檔名不一定是三個字 : 又些檔案又根本沒有副檔名 : 想請問這樣的話 : 要怎麼寫比較好? // ####################### file_extension ##################### function file_extension($fileName){ //取得主檔名,回傳值為 My.File (最後一個 . 之前的字串都視為主檔名) $main = substr($fileName,0,strrpos($fileName,'.')); //取得副檔名,回傳值為 php (沒有 . 喔!) $extend = array_pop(explode('.',$fileName)); //若為避免在不同作業系統下出問題請自行使用轉小寫函式 $extend = strtolower($extend); return $extend; } 之前看版友寫的,給您參考看看,我覺得不錯 -- AppleBoy Blog: http://blog.wu-boy.com -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.123.107.202
hirabbitt :謝謝 09/16 10:58