Hi, I am new to php and stuck with a problem, need some help
I have a field in mysql table that stores tags separated by comma. Now I am using the explode function to separate the tags and display them separtely ... it works fine if theres a space after the comma .... that is like, tag1, tag2, tag3 etc... but if the user doesnt leave a space after the comma ..it doesnt work .. say for example, tag1, tag2,tag3 ..in this case only tag1 and tag2 gets displayed not tag3 .... what am i doing wrong here? here's my code ..
$stags = explode(", ", $a);
$result = count($stags);
for($n = 0; $n < $result; $n++)
{
$stags = explode (",", $a);
echo trim($stags [$n]);
}
Help with explode
Moderator: General Moderators
Re: Help with explode
Code: Select all
$stags = explode(",", $a);
$result = count($stags);