0

(这是通过 PHP 调用的)我有以下内容:

"SELECT name FROM user WHERE uid IN (SELECT uid1 FROM friend WHERE uid2={$user})"

SQL 执行得非常好,但是,结果是一个数组,其中键是“名称”。我希望每个结果的键都是被搜索以提取该名称的相应uiduser

例子:

现在怎么样了

如果name是“Bob”而他uid是“12345”,我希望返回数组是 - [name] => Bob

我希望它是怎样的

如果name是“Bob”而他uid是“12345”,我希望返回数组是 - [12345] => Bob

编辑(根据评论请求):

$fql = "SELECT pic FROM user WHERE uid IN (SELECT uid1 FROM friend WHERE uid2={$user})";
        $param = array(
            'method' => 'fql.query',
            'query' => $fql,
            'callback' => ''
        );
$result = $facebook->api($param);
4

1 回答 1

2
$newResult = array();
foreach ($result as $entry)
{
    $newResult[$entry['uid']] = $entry['name'];
}
于 2012-05-13T00:43:21.827 回答