這篇文章運(yùn)用簡(jiǎn)單易懂的例子給大家介紹php如何利用explode函數(shù)分割字符串到數(shù)組,代碼非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
成都創(chuàng)新互聯(lián)主營(yíng)蘭坪網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶APP開(kāi)發(fā),蘭坪h5小程序定制開(kāi)發(fā)搭建,蘭坪網(wǎng)站營(yíng)銷(xiāo)推廣歡迎蘭坪等地區(qū)企業(yè)咨詢
//利用 explode 函數(shù)分割字符串到數(shù)組
代碼如下:
<?php $source = "hello1,hello2,hello3,hello4,hello5";//按逗號(hào)分離字符串 $hello = explode(',',$source); for($index=0;$index<count($hello);$index++) { echo $hello[$index];echo "</br>"; } ?> //split函數(shù)進(jìn)行字符分割 // 分隔符可以是斜線,點(diǎn),或橫線
代碼如下:
<?php $date = "04/30/1973"; list($month, $day, $year) = split ('[/.-]', $date); echo "Month: $month; Day: $day; Year: $year<br />\n"; ?>
通過(guò)數(shù)組實(shí)現(xiàn)多條件查詢的代碼
代碼如下:
<?php $keyword="asp php,jsp"; $keyword=str_replace(" "," ",$keyword); $keyword=str_replace(" ",",",$keyword); $keyarr=explode(',',$keyword); for($index=0;$index<count($keyarr);$index++) { $whereSql .= " And (arc.title like '%$keyarr[$index]%' Or arc.keywords like '%$keyarr[$index]%') "; } echo $whereSql;
關(guān)于php如何利用explode函數(shù)分割字符串到數(shù)組就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
分享標(biāo)題:php如何利用explode函數(shù)分割字符串到數(shù)組
文章轉(zhuǎn)載:http://m.kartarina.com/article28/jedjcp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站營(yíng)銷(xiāo)、微信小程序、網(wǎng)站設(shè)計(jì)公司、ChatGPT、網(wǎng)頁(yè)設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)