note 95492 added to function.strcasecmp

From: Date: Wed, 06 Jan 2010 07:24:34 +0000
Subject: note 95492 added to function.strcasecmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-164675@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/95492 Del: integrated -- https://master.php.net/note/delete/95492/integrated Del: useless -- https://master.php.net/note/delete/95492/useless Del: bad code -- https://master.php.net/note/delete/95492/bad+code Del: spam -- https://master.php.net/note/delete/95492/spam Del: non-english -- https://master.php.net/note/delete/95492/non-english Del: in docs -- https://master.php.net/note/delete/95492/in+docs Del: other reasons-- https://master.php.net/note/delete/95492 Reject -- https://master.php.net/note/reject/95492 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164675) next »