I have talked a lot about how to get the extension name of a file. Today we will summarize how to use different functions to obtain the extension name. If you need it, please refer to it.
One, php explode function, function usage reference http://www.bKjia. c0m/phper/24/f486bb8b0528a628528530b295e6281b.htm
The Code is as follows: |
Copy code |
$ Pic = 'abc. php '; $ Pics = explode ('.', $ pic ); Echo $ num = count ($ pics ); Echo '<br>'. $ pics [$ num-1]; |
In this way, you can output
. Php.
The following uses foreach this function to use http://www.bKjia. c0m/phper/18/foreach-foreach.htm
The Code is as follows: |
Copy code |
Foreach ($ pics as $ value) // 2 { $ A = $ value; } Echo $ a. '<br> '; |
To have a better function end I recommend using this function quick end function usage http://www.bKjia. c0m/w3school/php/func_array_end.htm
The Code is as follows: |
Copy code |
Echo end ($ pics ); Echo '<br> '; |
Other access methods can be determined during file upload. However, we cannot use $ _ FILES for file upload without uploading.