Im trying to do a foreach loop to get all the value
in an array & another loop for addresses
.
My code:
$json = json_decode($response, true);
foreach($json["result"]["vout"]["value"] as $a)
{
echo "<br> $a";
}
{
"result": {
"vout": [
{
"value": 0.09998700,
"n": 0,
"scriptPubKey": {
"addresses": [
"16Tjr2hz67mQW1YHpSLnKKDoXi4na6D66W"
]
}
},
{
"value": 1.63707231,
"n": 1,
"scriptPubKey": {
"addresses": [
"1LSnED1PUpssw9JAa2PPsypmjKrnMfz6u3"
]
}
},
{
"value": 5.00000000,
"n": 2,
"scriptPubKey": {
"addresses": [
"17BkwbuiiDqMQGqBomZeR2XUmKzhv8EwDg"
]
}
}
],
"confirmations": 2885,
"time": 1620396315,
"blocktime": 1620396315
},
"error": null,
"id": "curltest"
}
Error:
Warning: Undefined array key "value" in C:\xampp\htdocs\test.php on line 27
Warning: foreach() argument must be of type array|object, null given in C:\xampp\htdocs\test.php on line 27
Small information:
$response
is a json object i get from a curl
$json
is the json formatted in the standard php array structure