Jump to content

help with explode


jaay

Recommended Posts

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]);

}

Link to comment
https://forums.phpfreaks.com/topic/186018-help-with-explode/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.