0

I have an array where i want only the one Field text from all array which is text only. i want all text from there.

stdClass Object
(
    [language] => en
    [textAngle] => 0
    [orientation] => Up
    [regions] => Array
        (
            [0] => stdClass Object
                (
                    [boundingBox] => 81,63,1340,1055
                    [lines] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [boundingBox] => 321,63,855,117
                                    [words] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [boundingBox] => 321,63,174,94
                                                    [text] => Set
                                                )

                                            [1] => stdClass Object
                                                (
                                                    [boundingBox] => 529,87,126,69
                                                    [text] => an
                                                )

                                            [2] => stdClass Object
                                                (
                                                    [boundingBox] => 693,65,483,115
                                                    [text] => example.
                                                )

                                        )

                                )

                            [1] => stdClass Object
                                (
                                    [boundingBox] => 218,182,1059,116
                                    [words] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [boundingBox] => 218,182,271,92
                                                    [text] => Treat
                                                )

                                            [1] => stdClass Object
                                                (
                                                    [boundingBox] => 521,203,504,95
                                                    [text] => everyOne
                                                )

                                            [2] => stdClass Object
                                                (
                                                    [boundingBox] => 1054,182,223,91
                                                    [text] => With
                                                )

                                        )

                                )

I want take out from here like [text]=>Set,[text]=>an,[text]=>example. eg set an example.

Output should be eg. only like set an example

1

1 Answer 1

1

Given your example class above, I would try something like this.

$text = '';
foreach ($class->regions[0]->lines as $line){
    foreach ($line->words as $word){
        $text = $text." ".$word->text;
    } 
}
print $text;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.