function blog_gettag(){
$terms = mysql_query('SELECT vid,name FROM term WHERE vid=2');
foreach ($terms as $term){
return $term->name;
}
}
When i invoke the function echo blog_gettag(). there is only one result. but when i change the function retrun to echo. then blog_gettag().it prints ok. why?
That’s because you’re only returning one item. You’re returning as soon as it finds the first item.
A solution would be to return an array with all tag names, like this:
You can then iterate over all tags like this: