This article mainly introduces common methods for obtaining file name suffixes in php. The example analyzes five common methods for obtaining file name suffixes in php, which has some reference value. For more information, see
This article mainly introduces common methods for obtaining file name suffixes in php. The example analyzes five common methods for obtaining file name suffixes in php, which has some reference value. For more information, see
This example summarizes common methods for obtaining filename Suffixes in php. Share it with you for your reference. The specific implementation method is as follows:
<? Phpheader ("Content-type: text/html; charset = UTF-8"); $ pic = "abc.jpg"; // method 1 $ pics = explode ('. ', $ pic); $ num = count ($ pics); echo $ pics [$ num-1]."
"; // Method 2 echo end ($ pics )."
"; // End () method, to obtain the last unit value of the array // The third method $ info = pathinfo ($ pic); echo $ info ['extension']."
"; // Method 4 echo pathinfo ($ pic, PATHINFO_EXTENSION )."
"; // Method 5 $ offset = strrpos ($ pic ,'. '); // calculate the position of the last occurrence of the specified string in the target string echo substr ($ pic, $ offset + 1);?>
I hope this article will help you with php programming.