Jump to content

help with array


daveoliveruk

Recommended Posts

Ok I have the following code:

 

$classmates = $class['ClassMateArray']['ClassMate'];
$db = $fbapp->get_table(DB_USER_ID);

$friendsSolutions = array();
foreach ($friends as $k => $v) 
{
	$classmate = "false";
	// get number of class mate postings
	$user = $db->find($v, 'uid');
	if (!isset($user[0]))
	{
		$numSolutions = 0;
		$fid = 0;
		$registered = false;
	}
	else 
	{
		$fid = $user[0]['bm_id'];
		$registered = true;

		foreach ($classmates as $key => $val) 
		{
			// check if friend is a class mate
			if ($key == "UserID") 
			{
				if ($val == $fid) 
				{
					$classmate = "true";
					//$showMsg = "true";
				}
				else 
				{
					$classmate = "false";
					// check if the user is pending here				
				}
			}
			// for the removal of class mates
			if ($key == "ClassMateID") 
			{
				$cid = $val;
			}
			if ($key == "SharingSolutions") 
			{
				$numSolutions = $val;
			}			
		}

	}

	// add to array
	$friendsSolutions[] = array( 
		'fid' => $v,
		'bid' => $fid,
		'cid' => $cid,
		'num' => $numSolutions,
		'classmate' => $classmate,
		'registered' => $registered
	);
}

 

Which when there is only one result in the array works fine and returns this:

 

Array

(

    [0] => Array

        (

            [fid] => 1079553185

            [bid] => 168326

            [cid] => 66

            [num] => 5

            [classmate] => true

            [registered] => 1

        )

 

)

 

But if there is more than one record in the array it breaks. Anyone have any ideas how to get around this? Any help would be great!

 

PS: I think its along the lines of incrementing this $classmates = $class['ClassMateArray']['ClassMate'][0];

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.