PHP 8.5.0 Alpha 4 available for testing

Voting

: seven plus zero?
(Example: nine)

The Note You're Voting On

Psudo - thepsudo at gmail dot com
14 years ago
For highlighting without the overhead of regex and without destroying capitalization, try this:

<?php
function highlight($needle, $haystack){
$ind = stripos($haystack, $needle);
$len = strlen($needle);
if(
$ind !== false){
return
substr($haystack, 0, $ind) . "<b>" . substr($haystack, $ind, $len) . "</b>" .
highlight($needle, substr($haystack, $ind + $len));
} else return
$haystack;
}
?>

This example uses HTML bold tags, but you can easily change the highlighting method.

<< Back to user notes page

To Top