0

Possible Duplicate:
php loop through associative arrays

i have this piece of code which gets me as an output an array like this here:

http://penelope-ns.net/fb/fig.jpg

How can i save the [name] as a variable $name?

The code i use to generate is this:

  $fbfriendlikes[$fbid]=$facebook->api('/'.$fbid.'/likes'); ///// Add this line
5
  • Wrap your output in <pre> tags to make it more readable. Commented Jun 25, 2012 at 12:21
  • can you please give me an example? because i don't know how to do it.. Commented Jun 25, 2012 at 12:21
  • 1
    View the page source on the script that is dumping that array out. You'll see the structure much more clearly, and it will become obvious how to access the name keys Commented Jun 25, 2012 at 12:21
  • Hi Michael, thanks for your reply... so i need to do something like var_dump($friendlikes) ? Commented Jun 25, 2012 at 12:22
  • @FeratDucellari Your image appears to be var_dump() output already. I'm saying just view the page source in your browser rather than viewing the HTML output in your browser, and you'll see all the formatting. Commented Jun 25, 2012 at 12:28

1 Answer 1

0

As far as I can see:

$fbid = 500591729;
$name = $array[$fbid] ['data'] [0] ['name'];

Or for all names:

foreach ($array as $fbid=>$value) {
    echo $value['data'][0]['name'];
}
Sign up to request clarification or add additional context in comments.

3 Comments

Yes..Thanks this is what i need... but how can i output all the names? any loop?
Updated the answer, though you could probably have found that out yourself using my first answer, right?
Thanks Jeroen, i appreciate your answer!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.