str_ends_with - kouji6309/SingleMVC GitHub Wiki

說明

檢查字串是否以特定字串結尾。
相同於 PHP 8 新函數 str_ends_with


原型

str_ends_with(string $haystack, string $needle) : bool
ends_with(string $haystack, string $needle) : bool // 已淘汰,將於未來移除

參數

  • haystack

    被搜尋的字串 。

  • needle

    尋找目標。若不是字串,將會被轉成字串。

回應

是否以特定字串結尾。


應用

檢查字串

if (str_ends_with('abcdefg', 'efg')) {
    output('text', '找到了');
} else {
    output('text', '找不到...');
}
⚠️ **GitHub.com Fallback** ⚠️