1

I've read the official documentation and a lot of docs on Google. I would like to print the user info, but when I run my code, I got this:

Array
(
[id] => xxxx
[name] => Vinicius 
[first_name] => Vinicius
[last_name] => M
[link] => http://www.facebook.com/xxx
[username] => vinicius
[birthday] => 01/04/1989
...

And my code is, to get the user info:

//if user is logged in and session is valid.
if ($user){
//get user basic description
$userInfo = $facebook->api("/$user");

And to show:

<?php d($userInfo);  ?>

I would like to print like this (or something like):

Name: Vinicius
Last name: M
Birthday: 01/04/1989

I followed the Thinkdiff tutorial. Lots of code from them.

How about nested arrays?

[location] => Array (
    [id] => 110703698957912
    [name] => Campinas, Sao Paulo 
)
Roflo
  • 235
  • 1
  • 9
  • 27

1 Answers1

2

Try this:

echo 'First name: ' . $userInfo['first_name'];
echo 'Last name: ' . $userInfo['last_name'];
echo 'Birthday: ' . $userInfo['birthday'];

For nested arrays like:

[location] => Array (
    [id] => 110703698957912
    [name] => Campinas, Sao Paulo 
)

You can access them by doing:

$userInfo['location']['id'];
$userInfo['location']['name'];
Roflo
  • 235
  • 1
  • 9
  • 27
Stanley
  • 5,057
  • 4
  • 34
  • 44