This article mainly introduces about how to get the file extension through PHP, has a certain reference value, now share to everyone, the need for friends can refer to
First Kind
substr (STRRCHR ("http://www.xxx.com/public/abc.jpg", '. '), 1); string strrchr (' string ', ' needle ') Gets the last position of the specified string in the string that appears to the end of the content int Strrpos (' string ', ' needle ') gets the string that appears in the last position of the specified string, String substr (' string ', ' position ') Intercepts the string from the specified position to the end of string strchr (' string ', ' needle ') gets the string that appears in the first position of the specified string to the end of the content int Strpos (' string ', ' needle ') Gets the first position in the string where the specified string appears
The second Kind
substr ($path, Strrpos ($path, '. ') + 1)
Third Kind
Array_pop (Explode ('. ', $path))
Fourth type
(PathInfo ($path)) [' extension '] pathinfo ($path) returns: ' DirName ' + string ' http://www.baidu.com/public ' (length=27) ' basename ' = String ' abc.jpg ' (length=7) ' extension ' + string ' jpg ' (length=3) ' filename ' = ' = String ' abc ' (LENGTH=3)
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!