第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

PHP替換字符串中最后一次出現(xiàn)的字符串?

PHP替換字符串中最后一次出現(xiàn)的字符串?

PHP
達(dá)令說(shuō) 2019-11-13 14:28:40
有誰(shuí)知道用一個(gè)字符串中的另一個(gè)字符串替換最后一個(gè)出現(xiàn)的字符串的快速方法?
查看完整描述

3 回答

?
慕桂英4014372

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超13個(gè)贊

您可以使用此功能:


function str_lreplace($search, $replace, $subject)

{

    $pos = strrpos($subject, $search);


    if($pos !== false)

    {

        $subject = substr_replace($subject, $replace, $pos, strlen($search));

    }


    return $subject;

}


查看完整回答
反對(duì) 回復(fù) 2019-11-13
?
慕容森

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超18個(gè)贊

另一種1-liner但沒(méi)有預(yù)浸料:


$subject = 'bourbon, scotch, beer';

$search = ',';

$replace = ', and';


echo strrev(implode(strrev($replace), explode(strrev($search), strrev($subject), 2))); //output: bourbon, scotch, and beer


查看完整回答
反對(duì) 回復(fù) 2019-11-13
?
繁星coding

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超4個(gè)贊

$string = 'this is my world, not my world';

$find = 'world';

$replace = 'farm';

$result = preg_replace(strrev("/$find/"),strrev($replace),strrev($string),1);

echo strrev($result); //output: this is my world, not my farm


查看完整回答
反對(duì) 回復(fù) 2019-11-13
  • 3 回答
  • 0 關(guān)注
  • 793 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)