Mark text in HTML

后端 未结 5 644
迷失自我
迷失自我 2021-01-14 03:39

I have some plain text and html. I need to create a PHP method that will return the same html, but with before any instances of th

5条回答
  •  醉话见心
    2021-01-14 04:40

    Taken from http://www.php.net/manual/en/function.preg-quote.php

    $textbody = "This book is very difficult to find.";
    $word = "very";
    $textbody = preg_replace ("/" . preg_quote($word) . "/",
                              "" . $word . "",
                              $textbody);
    

提交回复
热议问题