I'm exploding on "." to get file format and name:
list($txt, $ext) = explode(".", $name);
The problem is that some files have names with dots.
How do I explote on the LAST "." so that I get $name=pic.n2
and $ext=jpg
from: pic.n2.jpg
?
Answer: No, Windows 10 does not have a duplicate finder in it yet.
If filename is empty or null, getExtension(String filename) will return the instance it was given. Otherwise, it returns extension of the filename. To do this it uses the method indexOfExtension(String) which, in turn, uses lastIndexof(char) to find the last occurrence of the '. '.
Use pathinfo:
$pi = pathinfo($name);
$txt = $pi['filename'];
$ext = $pi['extension'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With