Jump to content

really confused, lol


Monkuar

Recommended Posts

//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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.