daveoliveruk Posted January 24, 2008 Share Posted January 24, 2008 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 https://forums.phpfreaks.com/topic/87634-help-with-array/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.