<?php //第一种 function get_extension($file) { $file = explode('.', $file); return end($file); } //第二种 function get_extension($file) { return substr(strrchr($file, '.'), 1); } 第三种 function get_extension($file){ return pathinfo($file)['extension']; } //第四种 function get_extension($file) { return substr($file, strrpos($file, '.') + 1); } //第五种 function get_extension($file) { $file = preg_split('/\./', $file); return end($file); } //第六种 function get_extension($file){ $file = strrev($file); return strrev(substr($file,0,strpos($file,'.'))); } //第七种 function get_extension($file) { return pathinfo($file, PATHINFO_EXTENSION); } //第八种 function get_extension($file) { preg_match_all('/\.[a-zA-Z0-9]+/',$file,$data); return !empty($data[0])?substr(end($data[0]),1):''; } //第九种 function get_extension($file){ return str_replace('.','',strrchr($file,'.')); } //暂时这么多,以后再补充 $file = "http://10.229.211.123:8081/M00/00/09/Ch8_CFaaMLqAO87JAACePvS0ZRk.webp"; $data = get_extension($file); var_export($data);
http://www.savh.cn/thread-119.htm
转载请注明:Savh.Cn 发表