note 79022 deleted from function.highlight-string by nlopess
| From: | nlopess@php.net | Date: | Thu, 08 Nov 2007 23:43:46 +0000 |
| Subject: | note 79022 deleted from function.highlight-string by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-132136@lists.php.net to get a copy of this message | ||
Note Submitter: Sujithfem at gmail dot com
----
I have enclosed the simple function for Text [array] Highlight without changing the own case,
<?php
function ShowPowerHighlight($Text,$Needle) {
for($j=0; $j< count($Needle); $j++){
if ($Needle[$j] != "") {
$TextTemp = "";
$i=0;
while($i<strlen($Text)){
if((($i + strlen($Needle[$j])) <= strlen($Text)) && (strcasecmp($Needle[$j],
substr($Text, $i, strlen($Needle[$j]))) == 0)) {
$TextTemp .= '<font style="background-color:#FFFF00">' . substr($Text,
$i , strlen($Needle[$j])) . '</font>';
$i += strlen($Needle[$j]);
}else {
$TextTemp .= $Text{$i};
$i++;
}
}
$Text = $TextTemp;
$TextTemp="";
}
}
return $Text;
}
$Text= "The PHP Hypertext Preprocessor is a programming language that allows web developers to
create dynamic content that interacts with databases,sample web site http://www.sujithfem.byethost32.com" ;
$Needle= array ("0"
=>"PHP","1"=>"web","2"=>"to","3"=>"byet");
echo ShowPowerHighlight($Text,$Needle);
?>
$Text= "The PHP Hypertext Preprocessor is a programming language that allows web developers to
create dynamic content that interacts with databases,sample web site http://www.sujithfem.byethost32.com" ;
$Needle= array ("0"
=>"PHP","1"=>"web","2"=>"to","3"=>"byet");