note 95493 added to function.strcasecmp

From: Date: Wed, 06 Jan 2010 07:24:59 +0000
Subject: note 95493 added to function.strcasecmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-164676@lists.php.net to get a copy of this message
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); ---- Server IP: 59.162.86.123 Probable Submitter: 125.17.19.5 ---- Manual Page -- http://www.php.net/manual/en/function.strcasecmp.php Edit -- https://master.php.net/note/edit/95493 Del: integrated -- https://master.php.net/note/delete/95493/integrated Del: useless -- https://master.php.net/note/delete/95493/useless Del: bad code -- https://master.php.net/note/delete/95493/bad+code Del: spam -- https://master.php.net/note/delete/95493/spam Del: non-english -- https://master.php.net/note/delete/95493/non-english Del: in docs -- https://master.php.net/note/delete/95493/in+docs Del: other reasons-- https://master.php.net/note/delete/95493 Reject -- https://master.php.net/note/reject/95493 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164676) next »