List Info

Thread: note 79022 added to function.highlight-string




note 79022 added to function.highlight-string
user name
2007-11-07 07:20:51
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&quo
t;);

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&quo
t;);
----
Server IP: 203.199.124.111
Probable Submitter: 125.17.19.1
----
Manual Page -- http://www.php.net/manual/en/function.highlight-string
.php
Edit        -- https://master
.php.net/note/edit/79022
Del: integrated  -- h
ttps://master.php.net/note/delete/79022/integrated
Del: useless     -- http
s://master.php.net/note/delete/79022/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/79022/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/79022/spam
Del: non-english -- 
https://master.php.net/note/delete/79022/non-english
Del: in docs     -- http
s://master.php.net/note/delete/79022/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/79022
Reject      -- https://mast
er.php.net/note/reject/79022
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )