0

我正在拨打 OCRWebservice.com 并收到这样的回复

object(stdClass)#5 (1) {
["OCRWSResponse"]=>
object(stdClass)#6 (2) {
    ["ocrText"]=>
        object(stdClass)#7 (1) {
            ["ArrayOfString"]=>
                object(stdClass)#8 (1) {
                    ["string"]=>
                            string(109) "......,......,- PHYSICIANS HAVE BIGGER STAKE IN PATIENT, TOTAL CARE UNDER MEDICARE ACOs AROUNDTHEINDUSTRY "
                }
        }
    ["ocrWSWords"]=>
        object(stdClass)#9 (0) {
        }
}
}

object(stdClass)#10 (1) {
["OCRWSResponse"]=>
    object(stdClass)#11 (2) {
        ["ocrText"]=>
            object(stdClass)#12 (1) {
                ["ArrayOfString"]=>
                    object(stdClass)#13 (1) {
                        ["string"]=>
                        string(21) "AROUNDTHEINDUSTRY 10 "
                    }
            }
        ["ocrWSWords"]=>
            object(stdClass)#14 (0) {
        }
}
}

我无法将其解析为 $response->OCRWSResponse->ocrText。我需要读取 ocrText 中的字符串值。

似乎返回了不止一个 OCRWSResponse。我需要遍历它们并获取所有 ocrText。有人可以帮忙吗?

4

1 回答 1

1

试试这个:

<?php
// $response is the response
echo $response->OCRWSResponse->ocrText->ArrayOfString->string;
?>
于 2012-08-13T11:58:32.113 回答