Extension file suffix gif * extension filewww.111cn.net.gif; echogetfix ($ file); The obtained value is gif. This method is the simplest and most practical. Let's get the script ec (2); script
In php, there are two functions: end () and current (). The former is to read the last element value of the array, and the latter is to read the first value of the array,
In this case, we can see that I use an endpoint to read the 111cn.gif file suffix gif.
*/
$ File = 'www.111cn.net.gif ';
Echo getfix ($ file );
// The obtained value is gif. This method is the simplest and the most practical. Let's take a look at method 2. This method reads the extension using substr.
$ File named 'aaa.gif ';
Echo substr ($ file, strpos ($ file, '.') + 1 );
// Method 3 Use Arrays
$ File = '111cn.gif ';
$ D111cn = explode ('.', $ file );
Echo $ d111cn [count ($ d111cn)-1];
Function getfix ($ l1 ){
Return end (explode ('.', $ l1 ));
}
// This article was originally posted on www.111cn.net and indicated the source