Thursday, 15 July 2010

php - Concatenation of exploded array of tags to a string with links -



php - Concatenation of exploded array of tags to a string with links -

with custom function below, aim give specific link each element of array of tags. input function string (tag1, tag2, tag3). output (in linked form) tag1,

“tag1,” okey why can not expect : “tag1, tag2, tag3” (in linked form)

i read examples in php.net , in site terms (array, explode, for, .=) couldn’t solve issue.

can guide me please

function tag_linkify ($article_tags) { $array_of_tags = explode(",", $article_tags); $sayac = count($array_of_tags); $linked_tags =""; ($i=0; $i<$sayac; $i++) { $linked_tags .= '<a href="'.'">'.$array_of_tags[$i].'</a>, '; } echo substr_replace($linked_tags, '', -1, 2); } tag_linkify (tag1,tag2,tag3);

thanksregards

improving on sedz post:

function tag_linkify ($article_tags) { $array_of_tags = explode(",", $article_tags); echo '<a href="">' . implode('</a>,<a href="">', $array_of_tags) . '</a>'; }

tag_linkify ("tag1,tag2,tag3");

btw. parameters in tag_linkify phone call miss quotation marks ,

'<a href="'.'">'

is same

'<a href="">'

php arrays for-loop explode string-concatenation

No comments:

Post a Comment