Monday, 17 September 2012

Lowercase Words To Uppercase Words

Hello Friends in this tutorials how to lowercase words will be replaced with upper/lowercase words to the use of DataBase.you to replace words in string with a tag where url is from database.  

$nodecontent="this is test NIke CaLLaway page redirect blah blah"

$query = "SELECT * FROM wordlist";
$rst = mysql_query($query, $con);
while($row = mysql_fetch_assoc($rst)) {
$nodecontent= str_ireplace(" ".$row['link']." ", " <a href='". $row['url'] ."'>". $row['link'] ."</a> ");

}


This *would* (in your example) output: 

this is test <a href="www.nike.com">nike</a> <a href="www.callaway.com">callaway</a> page redirect blah blah" 

instead of 

this is test <a href="www.nike.com">NIke</a> <a href="www.callaway.com">CaLLaway</a> page redirect blah blah" 


Note the lowercase words will be replaced with the upper/lowercase version that is in the DB.
 

0 comments:

Post a Comment