Convert string to array and perform foreach, codeigniter
Explode them into an array:
<?php$all_tags = explode( ',' , $p['tags'] );foreach ( $all_tags as $one_tag ){ echo '<a href="#">' . $one_tag . '</a>';}
The explode() function splits the string using a delimiter (in this case the ',' comma) and each item is passed into the array.
I'm not sure I understand what you're asking correctly. Is this what you want?
$var = 'news, lastest';$tmp = explode(', ', $var);$result = '<a href="#">'.implode('</a>, <a href="#">', $tmp).'</a>';var_dump($result);// string(42) "<a href="#">news</a>, <a href="#">lastest</a>"