PHP str_replace with wild card?

前端 未结 1 748
渐次进展
渐次进展 2020-12-20 17:50

I know how to use str_replace for simple tasks, like this...

$Header = str_replace(\'

Animals

\', \'

Animals

\', $Heade
1条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-20 18:21

    You can use the str_replace() technique that has been suggested in the primary comments, but I believe preg_replace() using regular expressions is the best practice for wildcard replacements.

    Animals
    

    Plants

    EOD; $str = preg_replace('/

    (.*?)<\/h3>/', '

    $1

    ', $str); echo $str;

    0 讨论(0)
提交回复
热议问题