Some time ago a friend asked me to write a function called ‘highlight’, just like the same as RubyOnRail’s highlight. Today spending about an hour on it and playin’ around with preg_replace and preg_quote there’s something ready.
Examples:
highlight(‘You searched for: rails’, ‘rails’);
Result:
You searched for: <strong class=”highlight”>rails</strong>
highlight(‘Hello, welcome to this page. This page is about cats and [...]
