i parse json document and put date in table and put id type (example 2, 3, 4) .
how to calc sum by id?
my code
<?php
$json=file_get_contents("https://pv.cec.md/app1/api/reports/GetElectionPresence?electionType=2");
$data = json_decode($json);
if (count($data->Circumscriptions)) {
// Open the table
echo "<table>";
// Cycle through the array
foreach ($data->Circumscriptions as $idx => $Circumscriptions) {
$a = $Circumscriptions->TotalVoted;
// Output a row
echo "<tr>";
echo "<td id='$Circumscriptions->Type'>$Circumscriptions->TotalVoted</td>";
echo "</tr>";
}
// Close the table
echo "</table>";
$b=array($a);
echo "Total = ". array_sum($b);;
}
?>
and i put it to online fidget https://paiza.io/projects/N9CHMtFrLp9fWqoE1uhvTQ