Home > Article > Backend Development > How to get file suffix (extension) in php
Function explanation: The strtolower() function converts a string to lowercase. The strrev() function reverses a string. The strpos() function returns the position of the first occurrence of a string within another string. That is to first find the position of the symbol '.', and then calculate the length of the extension. Then use the total length of the string minus the length of the extension to calculate the length that needs to be intercepted. Recall the multiple methods of obtaining file extensions we introduced before: Three ways to get file extension in php (improved version) Summary of methods to obtain php file extension Three ways to get file extension in php 5 ways to get file extension in php A php custom function to get the file extension Several ways to get file extensions in php All roads lead to happiness. I hope you can find the bright sunshine on the road of learning in Programmer's Home and accompany you to spend a good time in your young and colorful life. |