How to add comma between array items PHP - Drupal -
How to add comma between array items PHP - Drupal -
i'm trying add together comma between these array items, if utilize implode returning array, array.
function boron_taxonomy_links($node, $vid, $type, $cat) { if (count($node->taxonomy)){ $tags = array(); foreach ($node->taxonomy $term) { if ($term->vid == $vid){ $tags[] = array('title' => $term->name . ',', 'href' => $type . '/' . $cat . '/' . $term->tid, 'attributes' => array('rel' => 'tag')); } } if ($tags){ homecoming theme_links($tags, array('class'=>'links inline')); } } }
when phone call implode on $tags, set comma inbetween string representations of objects in array. in case, objects arrays php doesn't know how turn string, uses string 'array'.
you'll want create sure $tags populated string formatted way want. since don't mention how want appear, i'll below example.
function termtostring($type, $cat, $term) { $title = $term->name . ','; $href = $type . '/' . $cat . '/' . $term->tid; $attribures = array('rel' => 'tag'); // combine string , homecoming homecoming "<a href=\"$href\" title=\"$title\" ref=\"{$attribures['rel']}\">$title</a>"; } function boron_taxonomy_links($node, $vid, $type, $cat) { if (count($node->taxonomy)) { $tags = array(); foreach ($node->taxonomy $term) { if ($term->vid == $vid) { $tags[] = termtostring($type, $cat, $term); } } if ($tags) { homecoming theme_links($tags, array('class' => 'links inline')); } } } php
Comments
Post a Comment