PHP 字符串 stripos()函數(shù)
stripos()是PHP的預定義函數(shù)。愛掏網(wǎng) - it200.com它用于查找一個字符串在另一個字符串中第一次出現(xiàn)的位置。愛掏網(wǎng) - it200.com
注意:此函數(shù)是不區(qū)分大小寫和二進制安全的。愛掏網(wǎng) - it200.com
stripos(string,find,start);
參數(shù) | 描述 | 必需/可選 |
---|---|---|
string | 指定要搜索的字符串。愛掏網(wǎng) - it200.com | 必需。愛掏網(wǎng) - it200.com |
find | 指定要查找的字符串。愛掏網(wǎng) - it200.com | 必需。愛掏網(wǎng) - it200.com |
start | 指定開始搜索的位置。愛掏網(wǎng) - it200.com | 可選。愛掏網(wǎng) - it200.com |
示例1
<?php
echo stripos("PHP is My Fav Language , I love php","PHP");
?>
輸出:
0
示例2
<?php
str=" PHP is My Fav Language";
echo "Before stripos() function:".str;
echo "<br>";
echo "After using stripos() function: ".stripos($str,"PHP");
?>
輸出:
Before stripos() function: PHP is My Fav Language
After using stripos(): 1
備注:當PHP開始時,有一個空格,因此使用’stripos()函數(shù)來查找字符串中”php”的第一次出現(xiàn)的位置。愛掏網(wǎng) - it200.com
參考:http://php.net/manual/en/function.stripos.php
聲明:所有內(nèi)容來自互聯(lián)網(wǎng)搜索結果,不保證100%準確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權益,可聯(lián)系我們進行處理。