Reputation: 244
I am building a blog which has tags.
The tags are saved to the DB like so tag1,tag2,tag3
I would like to display these separately is there a way to separate these when echoing them out?
Thanks
Upvotes: 0
Views: 79
Reputation: 11845
$pizza = "piece1,piece2,piece3,piece4,piece5";
$pieces = explode(",", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
Use count
with a for
loop or just a foreach
to iterate over the array $pieces
foreach($pieces as $key => $value) {
echo $value;
}
Upvotes: 1