Monkuar Posted February 6, 2012 Share Posted February 6, 2012 //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>"; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END This shows all my subforums on my forum, but 1 problem, if I try to seperate them, like let's say with a "comma" by using: //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END It will show the , BEFORE the link? so weird, here is the function: $forum_data['subforums'] = "<br> <span class=desc4>Subforums:</span> "; foreach($this->children[ $forum_data['id'] ] as $idx => $data) { //-------------------------------------- // Check permissions... //-------------------------------------- if ( $std->check_perms($data['read_perms']) != TRUE ) { continue; } // Do the news stuff first if (isset($data['last_title']) and $data['last_id'] != "") { if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $data['id']) ) { $this->news_topic_id = $data['last_id']; $this->news_forum_id = $data['id']; $this->news_title = $data['last_title']; } } if ($data['last_post'] > $newest['last_post']) { //Subforum last_title? $newest['last_post'] = $data['last_post']; $newest['fid'] = $data['id']; //$newest['id'] = $data['id']; $newest['last_id'] = $data['last_id']; $newest['last_title'] = $data['last_title']; $newest['password'] = $data['password']; $newest['last_poster_id'] = $data['last_poster_id']; $newest['last_poster_name'] = $data['last_poster_name']; $newest['status'] = $data['status']; $newest['star'] = $data['star']; } $newest['posts'] += $data['posts']; $newest['topics'] += $data['topics']; $printed_children++; //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END } How can I make it so it doesn't show the , before the FIRST link on that subforums variable, but only after every link and beyond? Okay I got it working by moving it ontop $forum_data['subforums'] .= "<a href=?z={$data[id]}>{$data['name']}</a>, "; //mod_KaLiTe_Subforums END $printed_children++; but now it shows the , after the last link, how do I make it so it doesn't show the comma for the last child? Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 6, 2012 Share Posted February 6, 2012 Put the content into an array and then implode() the array with the commas. Before the foreach() loop define a temp array $subforums = array(); Then, inside the foreach() loop generate the content like this: $subforums[] = "<a href=\"?z={$data['id']}\">{$data['name']}</a>"; Lastly, after the foreach() loop, implode() the temp array values using a comma and assign to $forum_data['subforums'] $forum_data['subforums'] = implode(', ', $subforums); Quote Link to comment Share on other sites More sharing options...
Monkuar Posted February 6, 2012 Author Share Posted February 6, 2012 Put the content into an array and then implode() the array with the commas. Before the foreach() loop define a temp array $subforums = array(); Then, inside the foreach() loop generate the content like this: $subforums[] = "<a href=\"?z={$data['id']}\">{$data['name']}</a>"; Lastly, after the foreach() loop, implode() the temp array values using a comma and assign to $forum_data['subforums'] $forum_data['subforums'] = implode(', ', $subforums); winner.. awesome Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.