str_replace 請問各位優秀的師兄師姐們,我想把字符串里相同部分換個顏色但不影響小大小寫
$row["name"]=str_replace($key, "<font color='red'>".$key."</font>", $row["name"]);
請問各位優秀的師兄師姐們,我想把字符串里相同部分換個顏色但不影響小大小寫,我試了半天還是不行,求助!這個是用于把查詢出來的關鍵詞用高亮表示,謝謝!
$row["name"]=str_replace($key, "<font color='red'>".$key."</font>", $row["name"]);
請問各位優秀的師兄師姐們,我想把字符串里相同部分換個顏色但不影響小大小寫,我試了半天還是不行,求助!這個是用于把查詢出來的關鍵詞用高亮表示,謝謝!
2017-05-01
舉報
2017-05-15
好像沒啥問題吧
<?php
$row["name"] = "I am abc,My name is abc,my home is abc!Love me ,hahaha";
$key = "abc";
$row["name"]=str_replace($key, "<span style='color:red;'>".$key."</span>", $row["name"]);
echo $row["name"];