0

I am making calls to OCRWebservice.com & receive a response like this

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) {
        }
}
}

I am unable to parse this as $response->OCRWSResponse->ocrText. I need to read the string value in ocrText.

There seems to be more than one OCRWSResponse returned. I need to loop thru them & get all the ocrText. Can someone pls help?

Uma Ilango
  • 968
  • 4
  • 16
  • 31

1 Answers1

1

Try this:

<?php
// $response is the response
echo $response->OCRWSResponse->ocrText->ArrayOfString->string;
?>
web-nomad
  • 6,003
  • 3
  • 34
  • 49