如何在PHP的foreach循环中组合两个查询?

Facebook API can give the pages a user admins. Suppose that it returns me the following array. Unfortunately it does not return the name of it or a url.

This turns me a list of page IDs.

$results = $facebook->api('/fql', array('q'=>'SELECT page_id, type FROM page_admin WHERE uid = me()'));

foreach($results['data'] as $result) {
    echo $result['page_id'], '<br />';
}

Using the follow I echo the name of the page ID.

$pagename = $facebook->api('/fql', array('q'=>'SELECT name FROM page WHERE page_id = 230127303706132'));
echo $pagename['data'][0]['name'];

My question is how can I have a list of the page names in an efficient way?
My guess is that I have to put the query inside the foreach loop.

First grab the page_ids

$results = $facebook->api('/fql', array('q'=>'SELECT page_id, type FROM page_admin WHERE uid = me()'));

$page_ids = array();
foreach($results['data'] as $result) {
    $page_ids[] = $result['page_id'];
}

Then get page names

$pagenames = $facebook->api('/fql', array('q'=>'SELECT name FROM page WHERE page_id IN (' . join(',', $page_ids) .')' ));

// list all page names
foreach($pagenames['data'] as $result) {
    echo $result['name'], '<br />';
}

Get it in one query

$pagenames = $facebook->api('/fql', array('q' => 'SELECT name FROM page WHERE page_id IN (SELECT page_id FROM page_admin  WHERE  uid=me())'));

// list all page names
foreach($pagenames['data'] as $result) {
    echo $result['name'], '<br />';
}
try this

$fql=https://graph.facebook.com/fql?q=SELECT name FROM page WHERE page_id in(SELECT page_id, type FROM page_admin WHERE uid = me())&access_token=xxxxxxxx;
$page_names =json_decode(file_get_contents($fql));
print_r($page_names);
It will show an array of page names.