0

I am trying to make a system that follow new user's Facebook friend automatically.

When a user log in to the website with their Facebook ID, the server store their Facebook id number into the db column.

Therefore, I would like to retrieve Facebook friend id numbers and match them to current signed user's Facebook ID numbers.

here is array data from Facebook friend.

Array (
    [data] => Array (
        [0] => Array (
            [name] => James1
            [id] => 1111
        )
        [1] => Array ( 
            [name] => James2
            [id] => 2222
        )
        [2] => Array (
            [name] => James3
            [id] => 3333
        )
        [3] => Array ( 
            [name] => James4
            [id] => 4444
        )
        [4] => Array ( 
            [name] => James5
            [id] => 5555
        ) [5] => Array ( 
            [name] => James6
            [id] => 6666
        )
    )
) 

I tried to use in_array PHP command, but didn't work.

Can you give me an idea how to make this?

2
  • Show us your code that didn't work. I suspect you weren't looking at the elements in the sub-array. Also, don't post personal data here! What you've done is actually a violation of Facebook TOS.
    – Brad
    May 7, 2012 at 3:01
  • @Brad I tried various code to match the numbers but didn't work well. I guess if I post wrong code here it will distract entire question.
    – james
    May 7, 2012 at 5:26

1 Answer 1

0

try:

foreach($yourArr['data'] as $val) {
   if($yourUserId == $val["id"]) {
      ///found
      break;
   }
}
0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.