溫馨提示×

stripos php 在哪里使用

PHP
小樊
88
2024-11-28 18:46:13
欄目: 編程語言

stripos() 是 PHP 中的一個字符串函數,它用于在字符串中查找一個子字符串,并返回其第一次出現的位置

<?php
$haystack = 'Hello, welcome to the world of PHP!';
$needle = 'PHP';

$position = stripos($haystack, $needle);

if ($position !== false) {
    echo "The substring '{$needle}' is found at position {$position} in the string '{$haystack}'.";
} else {
    echo "The substring '{$needle}' is not found in the string '{$haystack}'.";
}
?>

在這個示例中,我們在字符串 $haystack 中查找子字符串 $needle(即 ‘PHP’)。stripos() 函數返回子字符串在源字符串中第一次出現的位置(從 0 開始計數)。如果子字符串不存在于源字符串中,則返回 false。

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