Home > Article > Backend Development > How to replace the search title keyword in php with red color
php search and replace red implementation method: first open the corresponding PHP file; then search for keywords through the "if(!empty($_GET['kws'])) {...}" method and Just replace all places containing keywords with red fonts.
Recommended: "PHP Video Tutorial"
php replace the search title keyword with red
//将包含关键字的地方全部替换为红色字体(不区分大小写) if(!empty($_GET['kws'])) //搜索关键字 { $k = trim($_GET['kws']); foreach($result as $key =>$value){ $result[$key]['title'] = str_ireplace($k, "<font color='red'>$k</font>", $value['title']); } }
The above is the detailed content of How to replace the search title keyword in php with red color. For more information, please follow other related articles on the PHP Chinese website!