파일 이름의 마지막 두 문자 / 숫자가 PHP의 숫자인지 확인하고 싶습니다.
if (CODE HERE) {
// runs script because last two characters are numbers
}
이것은 그것을 설정해야합니다.
http://www.nws.noaa.gov/weather/images/fcicons/hi_shwrs20.jpg
The last two digits are '20'
다음은 안됩니다.
http://www.nws.noaa.gov/weather/images/fcicons/skc.jpg
There are no last two digits
이것은 트릭을 할 것입니다.
<?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;
}
?>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다