Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

PHP – ฟังก์ชัน mb_strripos()

ฟังก์ชัน mb_strripos() ใน PHP ใช้ค้นหาตำแหน่งสุดท้ายของ string ในอีก string หนึ่ง ฟังก์ชันนี้ ไม่ case-sensitive ทำ multibyte safe strripos() operation ตามจำนวน characters คืนค่าตำแหน่ง needle นับจากต้น haystack string

Syntax

integer mb_strripos( $str_haystack, $str_needle, $integer_offset=0, $str_encoding )

Parameters

mb_strripos() รับ 4 พารามิเตอร์:

  • str_haystack – string ใช้หาตำแหน่ง last occurrence ของ needle

  • str_needle – string ที่ต้องการหาจาก haystack

  • integer_offset – ตำแหน่ง needle ใน haystack ที่เริ่มค้นหา

  • str_encoding – character encoding name หาก omit จะใช้ internal encoding

Return Values

คืนค่าตำแหน่ง numeric ของ last occurrence ของ needle ใน haystack คืนค่า False หากไม่เจอ needle

ตัวอย่าง

<?php
// UTF-8 Encoding
// String needle Wo
// String Hello World
$string = mb_strripos("Hello World","Wo",0, "UTF-8");
// Output
var_dump($string);
?>

Output

int(6)