How do I replace certain parts of my string?

后端 未结 5 995
孤独总比滥情好
孤独总比滥情好 2020-11-22 04:29

How can I replace a certain part of my string with another one?

Input string:

\"Hello, my name is Santa\"

How can I change all

5条回答
  •  不知归路
    2020-11-22 04:48

    Use function preg_replace()

    $text ='this is the old word';
    
    echo $text;
    echo '
    '; $text = preg_replace('/\bold word\b/', 'NEW WORD', $text); echo $text;

提交回复
热议问题