A very extreme example, a way of solving a problem in disguise, recorded for later use.
How to remove the suffix from the default file name?
$fileName = a.txt
Two methods:
1: Borrow PHP’s strrchr+trim method: strrchr(string1,string2) returns the part from the end of string1 to the first encounter of string2 , returned together with string2.
The suffix is generally . }
2: Borrow PHP's strrpos+substr method: strrpos(string1,string2) returns the position of the last occurrence of string2 in string1, substr(string1,num1,num2) intercepts the string from num1 to num2 in string1.
Also with the help of "."
$pos = strrpos($fileName,".");
if($pos){
$fileName = substr($fileName,0,$pos);
}
This is a very extreme example, and this processing is not very careful. If the name $fileName = a.b.c.d, without a suffix, it will be processed in the same way:)