Reputation: 1862
im trying to extract every file extension of an uploaded file. For example:
example.doc -> .doc
another.example.jpeg -> .jpeg
even.anaother.example.pdf -> .pdf
i know this could be resolved by using regex, but regex are a closed book to me. So i need your help :( please
thanks in advance!
Upvotes: 2
Views: 1415
Reputation: 31508
Alternatively, don't do regex but use a built-in: pathinfo()
$ext = pathinfo($path, PATHINFO_EXTENSION);
Upvotes: 5
Reputation: 157889
in fact, this could be resolved by using nearly dozen methods. strrpos() + substr(), pathinfo(), explode()+end() are examples.
Upvotes: 1