It is required to extract the values with the identifier "text" from all the JSON nodes of the string in order to assemble an expression (sentence) at the output.
Question: how to sort through all elements of this JSON string?
{ "language": "ru", "textAngle": 0.0, "orientation": "Up", "regions": [ { "boundingBox": "42,12,596,465", "lines": [ { "boundingBox": "42,12,557,49", "words": [ { "boundingBox": "42,13,64,41", "text": "ты" }, { "boundingBox": "120,13,175,48", "text": "БУДЕШЬ" }, { "boundingBox": "309,12,198,43", "text": "визжать" }, { "boundingBox": "521,13,78,41", "text": "как" } ] }, { "boundingBox": "180,71,286,49", "words": [ { "boundingBox": "180,71,286,49", "text": "МАНДРАГОРА," } ] }, { "boundingBox": "70,422,506,49", "words": [ { "boundingBox": "70,422,135,49", "text": "когда" }, { "boundingBox": "216,422,235,43", "text": "ПОЛУЧИШЬ" }, { "boundingBox": "465,423,111,41", "text": "мня" } ] }, { "boundingBox": "569,465,69,12", "words": [ { "boundingBox": "569,465,54,12", "text": "riSOVach." }, { "boundingBox": "625,469,13,7", "text": "ru" } ] } ] } ] }
$words[] = array_walk_recursive(function ($value, $key){ if ($key == 'text'){ return $value; } }); echo implode(' ', $words);$words[] = array_walk_recursive(function ($value, $key){ if ($key == 'text'){ return $value; } }); echo implode(' ', $words);- Roman Kozin