我有此数据作为回应:

stdClass Object
(
[GetReceiveMessagesResult] => stdClass Object
    (
        [Messages] => Array
            (
                [0] => stdClass Object
                    (
                        [MessageID] => 63012240
                        [RecipientNumber] => 30006708212212
                        [SenderNumber] => 09379580052
                        [Body] => Esm200aliaranbeigi
                        [ReceiveDate] => 1482389480
                    )

                [1] => stdClass Object
                    (
                        [MessageID] => 63012231
                        [RecipientNumber] => 30006708212212
                        [SenderNumber] => 09379580052
                        [Body] => Esp243محسن قائدی
                        [ReceiveDate] => 1482389454
                    )

            )

    )

)


如何打印Messages项目?

$counter=count($results->GetReceiveMessagesResult->Messages);

最佳答案

您可以使用foreach循环

尝试

foreach ($results->GetReceiveMessagesResult->Messages as $msg)
{
    echo $msg->MessageID;
}

关于php - 如何解析stdclass,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41278041/

10-10 23:46