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
https://forums.phpfreaks.com/topic/256519-really-confused-lol/
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
https://forums.phpfreaks.com/topic/256519-really-confused-lol/#findComment-1315011
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
https://forums.phpfreaks.com/topic/256519-really-confused-lol/#findComment-1315014
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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