0

(This is called via PHP) I have the following:

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

The SQL executes perfectly fine, however, the result is an array where the key is "name". I would like each result's key to be the respective uid in user that was searched to pull that name.

Example:

How it is right now

If the name was "Bob" and his uid was "12345", I would like the return array to be - [name] => Bob.

How I would like it to be

If the name was "Bob" and his uid was "12345", I would like the return array to be - [12345] => Bob.

EDIT (as per the comment request):

$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);
1
  • Show us some code. How are you executing the query? What does this have to do with Facebook? Commented May 13, 2012 at 0:39

1 Answer 1

2
$newResult = array();
foreach ($result as $entry)
{
    $newResult[$entry['uid']] = $entry['name'];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.