Highlight searched substring with php (23.06.2016)
Simple text highlighter on PHP, useful to mark search results.

$search = $_GET["search"]; //exists check ommited
$text = "Content in which to search here";

//i modifier to ignore case, u for utf-8 (cyrillic supported)
$search ? preg_replace("/".($search)."/iu", '<i>\0</i>' , $text) : $text;
PHP
comments powered by Disqus
JavaScript (13)
PHP (11)
Brainfuck (8)
adm (8)
Joomla (4)
Canvas (3)
answers (2)
API (2)
CMS (2)
Modx (2)
jQuery (1)
Ajax (1)
SQL (1)
Shell (1)
batch (1)
10-6