I send a request and get back JSON, so I convert that JSON to an array, but I cannot use the array with my php:
$all_transactions_raw = file_get_contents("xxx");
$all_transactions = json_decode( $all_transactions_raw );
foreach ( $all_transaction as $transaction ) {
echo $transaction;
}
First part of the very long output:
Array (
[data] => Array (
[transactions] => Array (
[0] => Array (
[id] => t1rtn-gsjkadfv
[date] => 2017-11-01
[amount] => -8847
[memo] =>
[cleared] => reconciled
[approved] => 1
[flag_color] =>
why does the above code not print a list of transactions given by the api request?
when I use print_r( $all_transactions ); I can print out a long string of what looks like an array but I cannot access the data contained in it as separate chunks. Am I missing something?
$transactionis also probably an array, so tryprint_r($transaction);in the loop asechowill probably fail.trueas the second argument to json_decode() to assure that you get the result as associative arrays instead of object. However, since we have no idea what the result looks like, I can't know if that's the issue or not. Please share the value of$all_transactions_raw.$all_transactions[1]and do something with that.json_decode()withouttrueas a second argument like in your code, I don't see how the result could be associative arrays instead of objects? What exactly is that array a dump of? The raw value or inside the loop?