[Solved] Find if last two characters in filename are numbers [closed]


This should do the trick.

<?php
    $filename = "http://www.nws.noaa.gov/weather/images/fcicons/skc23.jpg";
    $posOfPeriod = strrpos($filename, ".");
    $last2digits = substr($filename, $posOfPeriod -2, 2);
    if (is_numeric($last2digits)) {
        echo "Numeric: ".$last2digits;
    }
    else {
        echo "Non-Numeric: ".$last2digits;
    }
?>

4

solved Find if last two characters in filename are numbers [closed]