note 95493 deleted from function.strcasecmp by danbrown

From: Date: Wed, 06 Jan 2010 15:52:31 +0000
Subject: note 95493 deleted from function.strcasecmp by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164692@lists.php.net to get a copy of this message
Note Submitter: John G.Sujith Kumar ---- highlight the string especially use for show the search result set............. function ShowHighlight($Text,$Needle) {//$Text is the string, $Needle is the text to be highlighted if ($Needle != "") { $TextTemp = ""; $i=0; while($i<strlen($Text)){ if((($i + strlen($Needle))<=strlen($Text))&& (strcasecmp($Needle,substr($Text,$i,strlen($Needle))) == 0)) { $TextTemp .= '<font class="SBG">' . substr($Text, $i , strlen($Needle)) . '</font>'; $i += strlen($Needle); } else { $TextTemp .= $Text{$i}; $i++; } } $Text = $TextTemp; } return $Text; } $Text= "The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases" ; $Needle= "PHP"; echo ShowHighlight($Text,$Needle);

« previous php.notes (#164692) next »