日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:52003
  • 待審:43
  • 小程序:12
  • 文章:1047590
  • 會(huì)員:762

php提供多種字符串截取函數(shù):substr():截取字符串指定部分。substring():從字符串末尾向起始位置截取子字符串。substr_replace():替換字符串指定部分。str_replace():替換字符串指定部分為其他部分。

PHP 中截取字符串的函數(shù)

PHP 提供了多種函數(shù)來截取字符串,其中最常用的包括:

substr(): 將字符串的一部分(子字符串)截取并返回。其語法為:substr(string $string, int $start, int $length = null),其中 $start 指定子字符串的起始位置,$length 指定子字符串的長度。

例如:

<code class="php">$string = "Hello World!";
$substring = substr($string, 0, 5); // "Hello"</code>

登錄后復(fù)制

substring(): 功能與 substr() 類似,但從字符串末尾向起始位置截取子字符串。其語法為:substring(string $string, int $start, int $length = null),其中 $start 指定子字符串的起始位置,$length 指定子字符串的長度。

例如:

<code class="php">$string = "Hello World!";
$substring = substring($string, 10, 5); // "World"</code>

登錄后復(fù)制

substr_replace(): 用指定字符串替換字符串中的一部分。其語法為:substr_replace(string $string, string $replacement, int $start, int $length = null),其中 $start 指定替換的起始位置,$length 指定替換的長度。

例如:

<code class="php">$string = "Hello World!";
$substring = substr_replace($string, "there", 7, 5); // "Hello there!"</code>

登錄后復(fù)制

str_replace(): 將字符串中的某些部分替換為其他部分。其語法為:str_replace(mixed $search, mixed $replace, mixed $subject),其中 $search 指定要替換的部分,$replace 指定替換后的部分,$subject 指定目標(biāo)字符串。

例如:

<code class="php">$string = "Hello World!";
$substring = str_replace("World", "there", $string); // "Hello there!"</code>

登錄后復(fù)制

分享到:
標(biāo)簽:PHP 函數(shù) 字符串 截取
用戶無頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 52003

    網(wǎng)站

  • 12

    小程序

  • 1047590

    文章

  • 762

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績?cè)u(píng)定