Hello all,
I want to hilight a certain part of a string (i.e. search result)
I have both the string and the substring in different varibales,
I want to hilight the substring and then pront the entire string with the specific part hilighted .
any ideas?
Thanks
hilight search word
Moderator: General Moderators
maybe this is sufficient
Code: Select all
<html>
<head>
<style type="text/css">
.hilight { color: red; text-decoration: bold; }
</style>
</head>
<body>
<?php
$subject = 'a teststring';
$hilight = 'test';
$output = str_replace($hilight, '<span class="hilight">'.$hilight.'</span>', $subject);
echo $output;
?>
</body>
</html>