ฟังก์ชั่น strripos()
ความหมายของฟังก์ชั่นและการใช้งาน
การค้นหาข้อความจากหลังไปหน้า ซึ่งจะคืนค่าตำแหน่งแรกที่พบหรือคืนค่า false ถ้าไม่พบ โดยไม่คำนึงถึงตัวพิมพ์เล็กพิมพ์ใหญ่ ด้วยฟังก์ชั่น strripos()
รูปแบบการเขียน (Syntax)
int strripos ( string $haystack , string $needle [, int $offset = 0 ] )
ตัวอย่างที่ 1
<?php
$haystack = 'ababcd';
$needle = 'aB';
$pos = strripos($haystack, $needle);
if ($pos === false) {
echo "Sorry, we did not find ($needle) in ($haystack)";
} else {
echo "Congratulations!\n";
echo "We found the last ($needle) in ($haystack) at position ($pos)";
}
?>