I need to read some data from a http URL with contains this data: {“result”:[{“reg”:408,“val”:670,“mod”:5}]}
I’ve done this in my Controller:
public function param(){
$http = new Client();
$response = $http->get('my https');
$json = $response->getJson();
$this->set("json", "$json");
}
And in my php file:
<!DOCTYPE html>
<html>
<head>
<title>Here the data</title>
</head>
<body>
<td><?php echo $json; ?></td>
</body>
</html>
But I receive the error: “Array to string conversion” in my Controller for the $this->set("json", "$json");
And in the php, it returns “Array” Why? How can I return the values?