Re: Adding link to entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



<?PHP


## list($DiaryContent, $DiaryLink) = mysql_fetch_row(mysql_query("SELECT
diaryContent, DiaryLink FROM mydb.diary WHERE date = 'YYYY-MM-DD'"));

$DiaryContent = 'Yo, Yo! Wassup. This is my Diary, my name is {name} and
this is a cool link to a website: {link}';
$DiaryReplace = '{name}*Bruce|{link}*<a
href="http://www.google.com";>www.google.com</a>|';


$DiaryReplace = explode('|', $DiaryReplace);

foreach($DiaryReplace AS $Replace)
{
 $Replace  = explode('*', $Replace);

 $DiaryContent = str_replace($Replace[0], $Replace[1], $DiaryContent);

}
echo $DiaryContent;

?>

There you go. Quick, clean, search and replace engine.

Regards,
Peter "Pod" Pistorius

peterp@podbox.co.za



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux