这是我的代码,我需要如何将百分比或数字添加到总计字段中的每个值我已经尝试了很多但没有任何效果。
<?php
$json=file_get_contents("http://www.upliftinghumanity.net/edd-api/sales/?key=75caa8cb60362c89e6ac2b62730cd516&token=6547d40b82cecb81cb7b0ec928554a9e&number=-1");
$data = json_decode($json);
extract(json_decode($json, true));
if (count($data->sales)) {
// Open the table
echo "<table>";
// Cycle through the array
foreach ($data->sales as $idx => $sales)
{
// Output a row
echo "<tr>";
echo "<td>$sales->total</td>";
echo "<td>$sales->total+3 </td>";
echo "<td>$sales->gateway</td>";
echo "<td>$sales->email</td>";
echo "<td>$sales->transaction_id</td>";
echo "</tr>";
}
// Close the table
echo "</table>";
}
?>
最佳答案
您可以在将其作为字符串回显之前添加它,例如 $somevar = $sales->data+1; echo "blahh $somevar";或者 echo "blahh {$somevar}";
@Ezekiel 按照您的建议解决了问题。我缺少一些基本的东西。谢谢——
关于javascript - 在检索到的 JSON API 数据中进行计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48069408/