Forum Moderators: coopster
$catids = 'Humor, Travel, Tragedy,'; //this is how its found in the database.
$category = explode(",",$catids);
$catsize = sizeof($category);
// for loop to print the category names with separator (pipe)
for($i=0;$i<$catsize-1;$i++) {
echo $category[$i]. " | ";
}
Humor | Travel | Tragedy |
$catids = 'Humor, Travel, Tragedy,'; //this is how its found in the database.
Is there a way to fix this?
$category = preg_split('/,/', $catids, -1, PREG_SPLIT_NO_EMPTY);
print implode(" | ", $category);
// Humor | Travel | Tragedy