title: Combining Multiple JSON arrays returned by Facebook Graph
body: <p>I've tried searching for how to merge arrays, maybe I have a Facebook specific issue. I'm trying to merge arrays which contain data about events the specific people are going to. Here is my PHP so far:</p>
  
  <pre><code>    //Define FQL Query
  $fql = "SELECT uid,education,name FROM user WHERE uid IN (SELECT uid1 FROM friend WHERE uid2=me())";
  $param = array(
                  'method'    =&gt; 'fql.query',
                  'query'     =&gt; $fql,
                  'callback'  =&gt; '');
  //Execute Query
  $fqlres = $facebook-&gt;api($param);
  //Start Blank Array
  $friend_events_array = '';
  //Loop through results and display events of students of a particular college
  foreach($fqlres as $friend){
      if($friend['education'] == ''){
          //If friend does not have an education_history array display Nothing
      }
      else {
          foreach($friend["education"] as $friendEd) {
              //If friend is a college student
              if($friendEd["type"] == "College") {
                  $collegeinfo = $friendEd;
                  $schoolinfo_friend = $collegeinfo['school'];
                      //If the name of the friend's college is the same as the user's college.
                      if ($schoolinfo_friend['name'] == $schoolinfo_user['name']){
                          echo $friend['name'].": ".$schoolinfo_friend['name'];
                          echo "&lt;br&gt;";
                          //Query Graph for Events
                          $friend_events = $facebook-&gt;api($friend['uid']."/events");
                          //Display Events
                          print_r($friend_events);
                          //Merge Arrays
                          $friend_events_array_new = array_merge($friend_events, $friend_events_array);
                          //Rename Array for Looping
                          $friend_events_array = $friend_events_array_new;
                      }
  
              }
  
          } 
  
      }
  }
  </code></pre>
  
  <p>First, I get a list of all the user's friends (I have all the necessary permissions like education_history, friends_events, and user_education_history. I first run through the list and get all the users that have an education array in their user object. Then I go into each education array and see if they are a college student, and then I check to see if their college matches the user's college. If that all checks out then I make an API call to the graph to get and Array of their events. Each event array returns successfully but I would like to know if it is possible to then try and merge each new Event Array in the Loop to a main event array that would grow with each friend that is processed.</p>
  
  <p>Thoughts?</p>
  
  <p>Also, each individual event array looks like this:</p>
  
  <pre><code>Array ( [data] =&gt; Array ( [0] =&gt; Array ( [name] =&gt; WU Alumni Meet [start_time] =&gt; 2011-10-21T17:00:00 [end_time] =&gt; 2011-10-23T13:00:00 [location] =&gt; Athletic Complex [id] =&gt; 197913876920275 [rsvp_status] =&gt; attending ) ) [paging] =&gt; Array ( [previous] =&gt; https://graph.facebook.com/3100772/events?limit=25&amp;since=1319216400 [next] =&gt; https://graph.facebook.com/3100772/events?limit=25&amp;until=1319216400 ) )
  </code></pre>
  
  <p>Does this matter?</p>