I made a search in the forum, and really I found a lot of examples, however no one works for me. Maybe (for sure) im doing something wrong. For that reason and if possible, I need assistance from you guys.
What I want? I want get the specific array from the json file.
Array:
array (
'Data' =>
array (
0 =>
array (
'Id' => 439201,
array (
),
'Members' =>
array (
0 =>
array (
'PortfolioId' => 439201,
'Id' => 100,
array (
'Id' => 1182,
'Symbol' => 'BTC',
),
'Amount' => 0.1,
'BuyPrice' => 4000,
),
1 =>
array (
'PortfolioId' => 439201,
'Id' => 200,
array (
'Id' => 1182,
'Symbol' => 'BTC',
),
'Amount' => 0.2,
'BuyPrice' => 5000,
)
)
)
)
)
I want print this way:
+----------+---------+----------+
| id | amount | BuyPrice |
+-------------------------------+
| 100 | 0.1 | 4000 |
+-------------------------------+
| 200 | 0.2 | 5000 |
+----------+---------+----------+
My php code:
$url = file_get_contents(dirname(__DIR__ ) . '/json/history.json');
$array = json_decode($url, TRUE);
foreach ($array as $items) {
foreach ($items as $key => $value) {
echo $value['Id'] . '|' . $value['amount'] . '|' . $value['BuyPrice'] . '<br>';
}
}