Page 1 of 1

Extracting Data from an array of objects

Posted: Wed Sep 08, 2010 2:44 am
by ajith_rock
Hi all,

I have a code which will ocr an image, and return the text from the image. The text is returned properly, however I am not able to extract it from the data-structure. When I tried to var_dump the variable, here is what I got :

stdClass Object
( [OCRWSResponse] => stdClass Object
( [ocrText] => stdClass Object
( [ArrayOfString] => stdClass Object
( [string] => THIRUKKURAL 61. On Truthfulness Is it asked 'What is truth?' It is the speaking of such words as are without the least degree of evil (to others). 1 Even falsehood has the nature of truth, if it confer a benefit that is free from fault. 2 Let not a man knowingly tell a lie; for after he has told the lie, his mind will burn him (with the memory of his guilt). 3 He, who in his conduct preserves a mind free from deceit, will dwell in the minds of all men. 4 He, who speaks truth with his heart, is superior to those who make gifts and practise austerities. 5 There is no praise like the praise of never utterin _. . I. without giving any suffering; it will leaI CH. 30
)
)
[ocrWSWords] => stdClass Object ( )
)
)

I want to extract the string "THIRUKKURAL 61. On Truthfulness Is it asked 'What is truth?' It is the speaking of such words as are without the least degree of evil (to others). 1 Even falsehood has the nature of truth, if it confer a benefit that is free from fault. 2 Let not a man knowingly tell a lie; for after he has told the lie, his mind will burn him (with the memory of his guilt). 3 He, who in his conduct preserves a mind free from deceit, will dwell in the minds of all men. 4 He, who speaks truth with his heart, is superior to those who make gifts and practise austerities. 5 There is no praise like the praise of never utterin _. . I. without giving any suffering; it will leaI CH. 30 " from the data-structure and display it.

Please help me out!!

Thanks in advance!!

Cheers,

--
Ajith

Re: Extracting Data from an array of objects

Posted: Wed Sep 08, 2010 3:19 am
by requinix
Try

Code: Select all

echo $variable->OCRWSResponse->ocrText->ArrayOfString->string;

Re: Extracting Data from an array of objects

Posted: Wed Sep 08, 2010 3:25 am
by ajith_rock
That was awesome!! It worked!!

Thanks a bunch!!

Cheers,

--
Ajith