Clan Adverts

Sponsors

CT on Facebook

Latest Product

User Box

Anonymous
38.107.179.216
Nickname:

Password:

Security Code
Security Code
Type Security Code


PND Downloads Feed

Phpnuke Downloads
How to Delete or Reset yo...
How to Delete or Reset your PHPNuke Admin Account
Lost your admin password ?  Cant login to your admin account ?This sh...
Back Online & Stuff
Back Online & Stuff
Look at us with our nifty website back up and running… Seriousl...
How to edit the admins in...
How to edit the admins in the forums
Here is a way to make someone admin in your forums on your Evo site. I...
Demo Splash Screen
Demo Splash Screen
Ped @ Clan Themes has released a simple splash screen entrance hack. ...
Free Phpnuke Business The...
Free Phpnuke Business Theme 6
This is the 6th Business theme for Phpnuke that Clan Themes has releas...
Tricked Out Slider
Tricked Out Slider
We have seen some great new things come out of Tricked Out News and th...

Custom Work

PHP Nuke Custom Work

www.clanthemes.com :: View topic - implode array
implode array

2 Replies / 513 Views


Post new topic   Reply to topic  

   www.clanthemes.com Forum Index » Modules

View previous topic :: View next topic


Noto
Reputation: 1043.9 Add RepSubtract Rep
votes: 13
Local time: 11:30 PM
Location: Sunny UK !
uk.gif

Site Admin
Site Admin

0.56 posts per day
Medals: 3 (View more...)
Site Supporter (Amount: 1)
Theme Guru
Theme Guru
Joined: May 03, 2007
Last Visit: 09 Feb 2012
Posts: 979
Points: 61141 

Post implode array Posted: Tue Feb 02, 2010 7:20 am

This has been drving me crazy, ive had this problem b4 and i know it was a simple fix but i just cant find it, any idea?

Code:
      $rankmembers = array();          
        while($row = $db->sql_fetchrow($tmember)){
      $rankmembers[$row['m_membername']][] = '<a href="">#</a><br>';
        }
      $membername = implode("<br>",$rankmembers);
      //$membername = print_r($rankmembers, true); //debug


Code:
$membername = implode("<br>",$rankmembers);

Output:

Array
Array
Array
Array

Code:
$membername = print_r($rankmembers, true); //debug

To see whats going on, output:

Array ( [member1] => Array ( [0] => #
) [member2] => Array ( [0] => #
) [member3] => Array ( [0] => #
) [member4] => Array ( [0] => #
) )
 

Tactical Combat Evolved - Sig Showcase  
View user's profileSend private messageVisit poster's website Reply with quote

monroe
Reputation: 569.9 Add RepSubtract Rep
votes: 2
Local time: 5:30 PM
Location: Pittsburgh
usa.gif

Rocket Noob
Rocket Noob

0.01 posts per day
Medals: 0

Joined: Apr 08, 2007
Last Visit: 26 Dec 2010
Posts: 20
Points: 1836 

Post Re: implode array Posted: Tue Feb 02, 2010 8:39 pm

Well your first problem is that $membername is a mult-dimensional array. I also do not think you can use implode on associative arrays.

Can you explain a little more what the $rankmembers is going to be used for? For one I don't understand why you are making it a multi-dimensional array. I don't see the need for the extra [] at the end of $rankmembers[$row['m_membername']][]. Also if you are just building the array to implode it you are going about it wrong. You should just use the while loop to make a variable that contains all the names and links and then just echo it out after the loop finishes.

I made a lot of assumptions here so If I am wrong correct me :)
 


Palbin  
View user's profileSend private messageVisit poster's website Reply with quote

Noto
Reputation: 1043.9 Add RepSubtract Rep
votes: 13
Local time: 11:30 PM
Location: Sunny UK !
uk.gif

Site Admin
Site Admin

0.56 posts per day
Medals: 3 (View more...)
Dedication (Amount: 1)
Theme Guru
Theme Guru
Joined: May 03, 2007
Last Visit: 09 Feb 2012
Posts: 979
Points: 61141 

Post implode array Posted: Tue Feb 02, 2010 10:25 pm

I was half a sleep when i made this thread after reading it just now i see i didnt explain it that well.

Recap* The main problem was only the word "array" was being echoed.

I have to use implode (*i think) because i need the array results inside another while loop.
eg:
Code:
whileloop       arrayresult
rank1 ->          "member1"
                     "member4"
                     "member6"
rank2 ->          ""
rank3 -> "member3"
and so on...


After a good night sleep
your right i dont need the extra [array] or half of the crap i had in there.
if i use
Code:
$membername = implode('<br>', array_keys($rankmembers));
this fixes my problem with only the word "array" being echoed.

with a few changes in the extra [array] area i now have the result im after. hack and slash i know but im happy LMAO
here it is
Code:
      $rankmembers = array();          
        while($row = $db->sql_fetchrow($tmember)){
        $m_membername = $row['m_membername'];
        $m_id = $row['m_id'];
      $rankmembers['<a href="' . $row['m_id'] . '"><strong>' . $row['m_membername'] . '</strong></a>'] = '';
        }
      //echo print_r($rankmembers, true); //debug
      $membername = implode('<br>', array_keys($rankmembers));


Thx for your time monroe!
 

 
View user's profileSend private messageVisit poster's website Reply with quote

Post new topic   Reply to topic  
   www.clanthemes.com Forum Index » Modules


 
2 Replies / 513 Views
Page 1 of 1
All times are GMT
Display posts from previous:   
 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum