ฟังก์ชั่น stripos()
ความหมายของฟังก์ชั่นและการใช้งาน
การค้นหาข้อความจากหน้าไปหลัง จะคืนค่าตำแหน่งแรกที่พบหรือคืนค่า false ถ้าไม่พบ โดยไม่คำนึงถึงตัวพิมพ์เล็กพิมพ์ใหญ่ ด้วยฟังก์ชั่น stripos()
รูปแบบการเขียน (Syntax)
mixed stripos ( string $haystack , string $needle [, int $offset = 0 ] )
ตัวอย่างที่ 1
<?php
$findme = 'a';
$mystring1 = 'xyz';
$mystring2 = 'ABC';
$pos1 = stripos($mystring1, $findme);
$pos2 = stripos($mystring2, $findme);
if ($pos1 === false) {
echo "The string '$findme' was not found in the string '$mystring1'";
}
if ($pos2 !== false) {
echo "We found '$findme' in '$mystring2' at position $pos2";
}
?>