Si l'on cherche à connaitre l'extension d'un nom de fichier (ex: 'index.html.twig' -> 'twig').
Il existe au moins deux façons d'y arriver.
1. Première façon
<?php
echo substr(strrchr($filePath,'.'),1);
2. Seconde façon
<?php
echo pathinfo($filePath, PATHINFO_EXTENSION);
3. Mauvais code
Le code suivant que l'on peut trouver ailleurs ne fonctionne pas :
<?php
echo str_replace('.','',strstr($filePath, '.'));
Ici, pour $filePath = 'index.html.twig', le résultat serait 'htmltwig', ce qui n'est pas le résultat attendu (on souhaite 'twig').