Forum Moderators: coopster
i am using the following code to so :
<?php $Keywords ="<a href=\"cat_sell.php?cid=" .$id. "\">" .$sbrow_off["sb_keywords"]."</a>";
echo str_replace(","," ¦ ", $Keywords );
?>
i got the keywords displayed as i wish them to be, but they appear as a single link.
what should i do to display them as separate links?
Thanks in advance for your help
yaz
$idand
$sbrow_off["sb_keywords"]. I have no idea where
$idis coming from, but I am guessing the latter variable is coming from the database as you mentioned. And it also looks as if the keywords are comma separated within that variable. So, explode [php.net] on the keywords first to get an array of keywords, then you could use the foreach [php.net] control structure to read each one and build your links accordingly.
<?
$str = $sbrow_off["sb_keywords"]; $keyword= explode(',', $str, -1);
$arr= print_r($keyword);
?>
The keywords stored in my database in the following way :
keyword1, keyword2, keyword3, keyword4
are now displayed in my browser like this
Array ( [0] => keyword1 [1] => keyword2[2] => keyword3 [3] => keyword4)
when i use the foreach :
<?
foreach ($arr as $k => $v ) {
echo "\$arr[$k] => $v.\n";?>
What can i do to solve the problem
thanks
yaz