溫馨提示×

php stristr 大小寫敏感怎樣設置

PHP
小樊
91
2024-11-19 08:11:34
欄目: 編程語言

在 PHP 中,stristr 函數本身是大小寫敏感的。如果你想要進行不區分大小寫的搜索,可以使用 stripos 函數。這是一個例子:

<?php
$haystack = "Hello World!";
$needle = "WORLD";

// 使用 stripos 進行不區分大小寫的搜索
$result = stripos($haystack, $needle);

if ($result !== false) {
    echo "Found '$needle' in '$haystack' at position " . ($result + 1) . ".";
} else {
    echo "'$needle' not found in '$haystack'.";
}
?>

在這個例子中,我們使用 stripos 函數來查找 $haystack 中不區分大小寫的 $needle。如果找到了,我們輸出結果;否則,我們輸出未找到的消息。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女