how to get the ["text"]=>
string(4) "head"
value to the php variable
From the below json
var_dump($result)
how to get the ["text"]=>
string(4) "head"
value to the php variable
From the below json
var_dump($result)
This should do it:
$result->tuc[0]->phrase->text;
You should really post the var_dump result in your question, and not just link to it, so the q&a remains on SO.
To handle json, PHP offers the json_encode
and json_decode
functions.
$array = [
'key' => 'value'
];
$jsonString = json_encode($array);
// Decoding will make your json into an object
// If you require json_decode() to output an array,
// you should pass true as a second parameter
$object = json_decode($jsonString);
$array = json_decode($jsonString, true);
// To access a value
echo $json->key;