Extracting Data from an array of objects

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ajith_rock
Forum Newbie
Posts: 11
Joined: Wed Sep 08, 2010 2:37 am

Extracting Data from an array of objects

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Extracting Data from an array of objects

Post by requinix »

Try

Code: Select all

echo $variable->OCRWSResponse->ocrText->ArrayOfString->string;
ajith_rock
Forum Newbie
Posts: 11
Joined: Wed Sep 08, 2010 2:37 am

Re: Extracting Data from an array of objects

Post by ajith_rock »

That was awesome!! It worked!!

Thanks a bunch!!

Cheers,

--
Ajith
Post Reply