Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and Replace

Status
Not open for further replies.

NateBro

Programmer
Sep 1, 2004
233
US
i have a search function on my website for a text file...
Code:
for ($i = 0; $i <= $#data; $i++){

 		if ($data[$i] =~ /$advance/) {
    		print "<p align='left'><b><font size='2' face='Arial' color='#66CCFF'>$data[$i]</font></b></p>\n";
    		
    	} 
}
but i want the $advance var to be replaced in the PRINT ""; statement with <span style='background-color: yellow'>$advance</span> so it will display the $advance var highlighted.

~Thanks Nate_Bro
 
Code:
for ($i = 0; $i <= $#data; $i++){
   if ($data[$i] =~ /$advance/) {
      $data[$i] =~ s/$advance/<span style='background-color: yellow'>$advance</span>/g;
      print "<p align='left'><b><font size='2' face='Arial' color='#66CCFF'>$data[$i]</font></b></p>\n";
   }
}
 
very awesome! thank you soooo much! it works great! :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top