php - JSON API data from Array to table
I'm a bit stuck trying to retrieve and display the correct information inside of a table, based on data obtained from an API and symbols which are stored in the database. In short, when I do this:
$div = file_get_contents("https://api.iextrading.com/1.0/stock/market/batch?symbols=$z&types=stats&filter=dividendRate");
$div = json_decode($div,TRUE);
foreach($div as $divi => $value) {
echo '<br/>'. $divi.' : '. $value['stats']['dividendRate'];
}
I get the correct outcome, which is this: FB : 0 GOOGL : 0 AAPL : 2.52
But this only shows it in a simple list, whereas if I want to display this in a table, I can only get it to show the correct symbols but the value for all is 2.52, no matter what. Code:
<td>
<?php
echo '<br/>'. $symbol[$x].' : '. $value['stats']['dividendRate'];
?>
</td>
Is it to do with the way I'm referencing this or something? If any additional code from the program is needed then let me know because this is obviously only a part of it. Thanks in advance!
Answer
Solution:
For some reason, this solved the issue: