中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

php在指定字符串中查找子字符串

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用

對strpos()函數(shù)可以用來在php中查找子字符串。strpos()函數(shù)將試圖找到子字符串在源字符串中首次出現(xiàn)的位置。如果找到了,它會(huì)返回一個(gè)非負(fù)整數(shù)表示子字符串出現(xiàn)的位置。 否則它會(huì)返回一個(gè)布爾值false。

<?php
$haystack1 = "2349534134345w3mentor16504381640386488129";
$haystack2 = "w3mentor234953413434516504381640386488129";
$haystack3 = "center234953413434516504381640386488129fyi";
$pos1 = strpos($haystack1, "w3mentor");
$pos2 = strpos($haystack2, "w3mentor");
$pos3 = strpos($haystack3, "w3mentor");
print("pos1 = ($pos1); type is " . gettype($pos1) . "\n");
print("pos2 = ($pos2); type is " . gettype($pos2) . "\n");
print("pos3 = ($pos3); type is " . gettype($pos3) . "\n");
?>

輸出結(jié)果
pos1 = (13); type is integer
pos2 = (0); type is integer
pos3 = (); type is boolean
  
pos3返回的是bool值,即沒有找到子字符串

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:如何將網(wǎng)絡(luò)流轉(zhuǎn)化為內(nèi)存流 C#

下一篇:C# 實(shí)現(xiàn)一個(gè)簡單的 HTTP 服務(wù)器