在std对象类中计算id

时间:2015-02-16 14:27:05

标签: php class object count std

以下是一些示例数据:



Array
(
[data] => Array
    (
        [0] => stdClass Object
            (
                [end_time] => 2015-03-01T03:00:00+0000
                [location] => Gunwharf Quays, PO1 3TP Portsmouth, England
                [name] => The Big Saturday Night Out
                [start_time] => 2015-02-28T17:00:00+0000
                [timezone] => Europe/London
                [id] => 886768311375602
            )

        [1] => stdClass Object
            (
                [end_time] => 2015-02-28T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Twisted Circus @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-27T17:00:00+0000
                [timezone] => Europe/London
                [id] => 786947358061132
            )

        [2] => stdClass Object
            (
                [end_time] => 2015-02-27T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Hi-Jack @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-26T21:00:00+0000
                [timezone] => Europe/London
                [id] => 1074505415908428
            )

        [3] => stdClass Object
            (
                [end_time] => 2015-02-24T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Cult @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-23T21:00:00+0000
                [timezone] => Europe/London
                [id] => 729085230544720
            )

        [4] => stdClass Object
            (
                [end_time] => 2015-02-22T03:00:00+0000
                [location] => Gunwharf Quays, PO1 3TP Portsmouth, England
                [name] => The Big Saturday Night Out
                [start_time] => 2015-02-21T17:00:00+0000
                [timezone] => Europe/London
                [id] => 609013512563725
            )

        [5] => stdClass Object
            (
                [end_time] => 2015-02-21T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Twisted Circus @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-20T17:00:00+0000
                [timezone] => Europe/London
                [id] => 749534875163136
            )

        [6] => stdClass Object
            (
                [end_time] => 2015-02-20T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Hi-Jack @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-19T21:00:00+0000
                [timezone] => Europe/London
                [id] => 971159842895886
            )

        [7] => stdClass Object
            (
                [end_time] => 2015-02-17T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Cult @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-16T21:00:00+0000
                [timezone] => Europe/London
                [id] => 1571601606417060
            )

        [8] => stdClass Object
            (
                [end_time] => 2015-02-15T03:00:00+0000
                [location] => Gunwharf Quays, PO1 3TP Portsmouth, England
                [name] => The Big Saturday Night Out Valentines Day Special
                [start_time] => 2015-02-14T17:00:00+0000
                [timezone] => Europe/London
                [id] => 287667738024362
            )

        [9] => stdClass Object
            (
                [end_time] => 2015-02-14T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Twisted Circus @ Tiger Tiger Portsmouth Valentines Weekend!
                [start_time] => 2015-02-13T17:00:00+0000
                [timezone] => Europe/London
                [id] => 331340820391327
            )

        [10] => stdClass Object
            (
                [end_time] => 2015-02-13T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Hi-Jack @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-12T21:00:00+0000
                [timezone] => Europe/London
                [id] => 1545834062332133
            )

        [11] => stdClass Object
            (
                [end_time] => 2015-02-10T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Cult @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-09T21:00:00+0000
                [timezone] => Europe/London
                [id] => 328156524053841
            )

        [12] => stdClass Object
            (
                [end_time] => 2015-02-08T03:00:00+0000
                [location] => Gunwharf Quays, PO1 3TP Portsmouth, England
                [name] => The Big Saturday Night Out
                [start_time] => 2015-02-07T17:00:00+0000
                [timezone] => Europe/London
                [id] => 495901040551321
            )

        [13] => stdClass Object
            (
                [end_time] => 2015-02-07T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Twisted Circus @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-06T17:00:00+0000
                [timezone] => Europe/London
                [id] => 791985410838656
            )

        [14] => stdClass Object
            (
                [end_time] => 2015-02-06T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Hi-Jack @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-05T21:00:00+0000
                [timezone] => Europe/London
                [id] => 421146541382639
            )

        [15] => stdClass Object
            (
                [end_time] => 2015-02-03T03:00:00+0000
                [location] => Tiger Tiger Portsmouth
                [name] => Cult @ Tiger Tiger Portsmouth
                [start_time] => 2015-02-02T21:00:00+0000
                [timezone] => Europe/London
                [id] => 817228511683302
            )

    )

[paging] => stdClass Object
    (
        [cursors] => stdClass Object
            (
                [before] => ODg2NzY4MzExMzc1NjAy
                [after] => ODE3MjI4NTExNjgzMzAy
            )

        [next] => https://graph.facebook.com/v2.2/423161897815426/events?access_token=CAALo1LbT87gBAOeqSCxTvZCuEjMlLjuHzfTVGFDXKneBuhPw2HnRB46lfOO8uGjJPZA8jiRflaCgjgdURqKRXXIYZB2aKZCnAkNaP5tSLQSTTDPHoTEtYH4CZBTI6eZCOduLm4n34lNEDM1nhT6OmmPWy6kfdbMVqdVtJGn0c9llK87trhYIZAfjXZCfMU2E7mPxZA3ET2Q4KWX0qfVxmtVwU&limit=25&after=ODE3MjI4NTExNjgzMzAy
    )

)




我希望能够计算出次数" id"出现,所以在这种情况下:16

通常我会使用count($ array)但不确定如何为std类对象中的特定项执行此操作。 谢谢,如果你能提供帮助

1 个答案:

答案 0 :(得分:0)

$ EventsCount = count($ graphObject [' data']); 这做了类似的事情,$ graphObject就是数组。