-2
mine foreach
is only returning to $key
and the $value
displays only Array
.
What could be wrong with my code?
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'https://www.instagram.com/p/CLm2laRsp8I/?__a=1');
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
$query = curl_exec($curl_handle);
$data = json_decode($query, true);
curl_close($curl_handle);
foreach ($data["graphql"]["shortcode_media"]["edge_media_to_parent_comment"]["edges"] as $array) {
foreach ($array as $key => $value) {
print "$key : $value<br>";
}
}
Return:
Warning: Array to string conversion
node : Array
Warning: Array to string conversion
node : Array
As you said yourself, your value is an array, you cannot print as if it were a string.
– Woss