PHP 8.4.24 Released!

Voting

: min(zero, four)?
(Example: nine)

The Note You're Voting On

Psudo - thepsudo at gmail dot com
15 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