0
A
回答
1
你可以做這樣的事情
<?php
$str="Hello World You are on StackOverflow";// Your large text
$arrMatchWords=array("World","on");// Provide all your matching text.
foreach($arrMatchWords as $k=>$v)
{
$str=str_replace($v,"<span style='background:#ffff00'>".$v."</span>",$str);
}
echo ($str);
OUTPUT:
0
$keywords = array("computers" => NULL,"paper" => NULL, "rocket" => NULL);
$text = preg_split('/\s/', $my_text_string);
foreach($text as $key => $value)
{
if(array_key_exists($value, $keywords)) {
echo $value . "\n";
$text[$key] = '<span style="background:yellow">'. $value . '</span>';
}
}
$my_text_string = implode(' ', $text);
echo $my_text_string;
?>
相關問題
- 1. 突出顯示搜索字詞
- 2. gridview不突出顯示搜索詞
- 3. 突出顯示搜索多個關鍵字(非英文字符)
- 4. 搜索多個關鍵詞
- 5. 在網絡搜索中突出顯示搜索字詞
- 6. ASP.NET MVC - 在搜索結果中突出顯示搜索字詞
- 7. Windows搜索 - IFilter搜索詞突出顯示
- 8. 設置多個textbox.SelectionStart值,突出顯示搜索詞
- 9. 突出顯示搜索TextBlock
- 10. 使用JavaScript在結果中突出顯示搜索關鍵字
- 11. 如何突出顯示網格中搜索的關鍵字
- 12. 突出顯示搜索結果中的關鍵字
- 13. ASP.Net中的搜索關鍵字突出顯示
- 14. 如何突出顯示搜索關鍵字
- 15. Netbeans熱鍵關閉突出顯示的搜索文本?
- 16. 突出顯示給定搜索文本中的關鍵字
- 17. 如何在Lucene.net中突出顯示搜索到的關鍵字?
- 18. 突出顯示搜索結果中的關鍵字php
- 19. 在PHP搜索腳本中突出顯示關鍵字
- 20. 突出顯示多個關鍵字
- 21. 搜索/突出顯示單詞文檔中的特定單詞
- 22. mysql和php搜索突出顯示
- 23. 使用JQuery搜索和突出顯示
- 24. 突出顯示關鍵字
- 25. 突出搜索關鍵字懸停
- 26. Hibernate的關鍵詞搜索
- 27. 智能關鍵詞搜索
- 28. nutch:用關鍵詞搜索
- 29. 彈性搜索中的多重匹配和突出顯示
- 30. 在Vim中僅突出顯示搜索詞的一部分