I have a file in PHP to sum values of a JSON file (sum.php) and in this file i put:
<?php
// Get json from url
$json = file_get_contents("file.json");
// Decode json into an array
//$json = json_decode($content, true);
$data = json_decode($json, TRUE);
// Set default
$total = 0;
// Loop through the array created when decoding json
foreach ($data as $key)
{
// remove symbol from the end leaving only digits
$value = substr(utf8_decode($key['initialContractualPrice']), 0, -1);
// remove the decimal point
$value = str_replace('.', '', $value);
// replace the comma with a decimal point
$value = str_replace(',', '.', $value);
// add this number to the total value
$total += $value;
}
echo $total;
?>
In other file that haves a button with a <input type="submit" name="soma" value="Somar Valores" class="btn btn-primary" formaction="sum.php"/>
to sum.php and when i click on this buttom doesn't show result on page.
How i resolve it, can you help me?