开发者

How do I get the Array total for stdClass Object?

开发者 https://www.devze.com 2023-02-20 13:46 出处:网络
I am trying to get the total for the Array in the Object. I am using 开发者_JAVA技巧print_r to get the following to see whats in it.

I am trying to get the total for the Array in the Object.

I am using 开发者_JAVA技巧print_r to get the following to see whats in it.

stdClass Object ( [data] => Array ( [0] => stdClass Object ( [name] => The Drift Bible [category] => Movie [id] => 227431881228 [created_time] => 2011-02-27T21:41:04+0000 ) [1] => stdClass Object ( [name] => Shooter [category] => Movie [id] => 109671005718938 [created_time] => 2011-02-16T09:18:29+0000 ) [2] => stdClass Object ( [name] => Tron [category] => Movie [id] => 99792857339 [created_time] => 2010-11-29T03:18:06+0000 ))

here is my code to get the information

$movies = json_decode(file_get_contents('https://graph.facebook.com/me/movies?' 
.'format=json&access_token=' . $session['access_token']));

Again I just need to get the Array value. Such as 3 in the about example above.

I am very new to this. Any advice will help.

Thanks


Try:

$c = count($movies->data)


    //creating facebook_id from facebook_url
$sRequestUrl = 'http://graph'.strstr($a_data['contact_data']['facebook'], '.facebook');

        $curl = curl_init();
        curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => $sRequestUrl
        ));
        $res = curl_exec($curl);
        curl_close($curl);
        $res = json_decode($res);

        id = $res->id;
            about = $res->about;

just call the name of the variable key

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号