Jump to content

Need To Add Extra Row To Var_Export


Monkuar

Recommended Posts

Okay see the code below:

 



$result = $db->query('SELECT g_id, g_user_title,g_color from groups where g_id != 3 AND g_id != 5 AND g_id != 4 AND g_id != 0 AND g_id != 12 ORDER BY g_moderator DESC') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());
while ($stats =$db->fetch_assoc($result)){


//Grab how many members each group has
   $result2 = $db->query('SELECT COUNT(group_id) as members from users where group_id = '.$stats['g_id'].'  ') or error('Unable to fetch forum topic count', __FILE__, __LINE__, $db->error());
list($totalmembers) = $db->fetch_row($result2);



$groupinfo[] = $stats;


}



$fh = @fopen(FORUM_CACHE_DIR.'cache_group_info.php', 'wb');
fwrite($fh, '<?php '."\n\n".'$ginfo = '.var_export($groupinfo, true).';'."\n\n".'?>');

 

 

Okay so when this works, it will create my cache_group_info.php file:

 


$ginfo = array (
 0 => 
 array (
   'g_id' => '2',
   'g_user_title' => 'title',
   'g_color' => '0F77FF',
 ),
 1 => 
 array (
   'g_id' => '9',
      'g_user_title' => 'title',
   'g_color' => '00CCFF',
 ),
 2 => 
 array (
   'g_id' => '1',
     'g_user_title' => 'title',
   'g_color' => 'FF0000',
 ),
 3 => 
 array (
   'g_id' => '7',
   'g_user_title' => 'title',
   'g_color' => 'EEB10A',
 ),
 4 => 
 array (
   'g_id' => '10',
    'g_user_title' => 'title',
   'g_color' => '5888BF',
 ),
 5 => 
 array (
   'g_id' => '13',
      'g_user_title' => 'title',
   'g_color' => '995454',
 ),
);

 

Now I want to add my "$totalmembers" array below each g_color with php only, I know the data is being called and created from the groups table, but is there a way to add it in with just php?

 

I've tried:

 

$groupinfo[$totalmembers][] = $stats;

 

And a bunch of other crap which doesn't work, if you can help I'd appreciate it greatly, thanks

Link to comment
Share on other sites

Update: I tried this:

 

$groupinfo[] = $stats;
array_push($totalmembers);

 

But this is not working either, (Couldn't edit my topic, sorry for double post)

 

 

Edit again:

 

Even tried:

 

$groupinfo[] = $stats;
array_merge($groupinfo, $totalmembers);

 

Still not working,

 

 

Edit 3rd:

 

tried:

 

$addme = array_push($groupinfo, 'test');

$groupinfo[$addme][] = $stats;

 

still fail

 

 

 

WHOA SO CLOSE!!

 

 

 

 




$total['members'] = $totalmembers;

$groupinfo[] = $stats;
array_push($groupinfo, $total);

 

 

But it shows:

 

 

$ginfo = array (
0 =>
array (
'g_id' => '2',
'g_user_title' => 'Moderator',
'g_color' => '0F77FF',
),
1 =>
array (
'members' => '1',
),
2 =>
array (
'g_id' => '9',
'g_user_title' => 'Jr. Moderator',
'g_color' => '00CCFF',
),
3 =>

 

It's making a new array, I need it to be added under g_color, so it shows:

 

'g_color' => '00ccFF',

'members' => '2',

 

 

I am so close, hope u can help hehe

Edited by Monkuar
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.