PHP Knowledge Base

Using variables in preg_replace()

Example

$text = preg_replace('/' . $search_string . '/i', "<b class=\"pop\">$search_string</b>", $text);