str_replace()
それらを強調表示する目的で、HTML文字列の周りにスパン要素を配置するために使用したいと思います。
ただし、文字列内にある場合、次は機能しません
。をに置き換えてみました
が' '
、これは役に立ちませんでした。
ライブの例
以下のコードを使用して問題を再現できます。
$str_to_replace = "as a way to incentivize more purchases.";
$replacement = "<span class='highlighter'>as a way to incentivize more purchases.</span>";
$subject = file_get_contents("http://venturebeat.com/2015/11/10/sources-classpass-raises-30-million-from-google-ventures-and-others/");
$output = str_replace($str_to_replace,$replacement,$subject);
.highlighter{
background-collor: yellow;
}