What are the functions in php to get the file suffix name?
Sep 02, 2019 am 10:33 AMphp file upload and multi-file upload are important and must be mastered. There are many methods for file upload. Here we mainly introduce several of them for your reference. For everyone’s reference.
1. String search and segmentation method
1 2 |
|
Analysis: strrchr($file, '.')
strrchr() function searches for strings The position of the last occurrence in another string and returns all characters from that position to the end of the string
1 2 |
|
Parsing: strrpos($file, '.')
Find " ." At the last position in the string, return the position substr() intercepts from this position
2. Array splitting method
1 2 3 4 5 6 7 8 |
|
Analysis :end() returns the last element of the array, and the strrev(string) function reverses the string.
3. Path function method
1 2 3 4 5 6 7 8 |
|
Analysis: The pathinfo() function returns the file path information in the form of an array.
The above introduces a total of 7 methods to obtain file extension names, for your reference only. If you want to know more related issues, please visit the PHP Chinese website: PHP Video Tutorial
The above is the detailed content of What are the functions in php to get the file suffix name?. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to optimize the lazy loading effect of images through php functions?

PHP Deprecated: Function ereg_replace() is deprecated - Solution

How to reduce memory usage through php functions?

Introduction to PHP functions: strtr() function

Similarities and differences between PHP functions and Flutter functions

Win11 file suffix display operation guide

Comparing PHP functions to functions in other languages
