stripos() 是 PHP 的預定義函數。它用於查找一個字符串在另一個字符串中第一次出現的位置。
注意:此函數不區分大小寫且二進製安全。
用法:
stripos(string,find,start);
參數 | 描述 | 必需/可選 |
---|---|---|
string | 指定要搜索的字符串。 | 必需的。 |
find | 指定要查找的字符串。 | 必需的。 |
start | 指定從何處開始搜索。 | 可選。 |
例子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() 函數用於查找字符串中第一次出現"php" 的位置。
參考:
http://php.net/manual/en/function.stripos.php相關用法
- PHP stripcslashes()用法及代碼示例
- PHP stripslashes()用法及代碼示例
- PHP strip_tags()用法及代碼示例
- PHP string rtrim()用法及代碼示例
- PHP string printf()用法及代碼示例
- PHP string ord()用法及代碼示例
- PHP string join()用法及代碼示例
- PHP string sha1()用法及代碼示例
- PHP string setlocale()用法及代碼示例
- PHP string sha1_file()用法及代碼示例
- PHP string md5()用法及代碼示例
- PHP string ltrim()用法及代碼示例
- PHP string str_repeat()用法及代碼示例
- PHP string lcfirst()用法及代碼示例
- PHP string str_shuffle()用法及代碼示例
- PHP string similar_text()用法及代碼示例
- PHP string crypt()用法及代碼示例
- PHP string str_ireplace()用法及代碼示例
- PHP stristr()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP stripos() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。