I have this code, perhaps not correct:
<?php echo round(" + json.list[0].number + ");?> // number is 25.54864869
I want round number to 25 but this code is wrong. How can I do?
<script language='javascript'>
$(document).ready(init);
function init() {
$.getJSON("file.json").done(onSuccess).fail(onError);
}
function onSuccess(json) {
console.log(json);
$("#box").html("<table style='border-collapse:collapse;border:1px solid #ddddcc;color:#000000;width:100%;text-aling:center;'>" +
"<tr><td style='width:25%;'> </td><td>" + json.list[0].dt_txt + "</td><td>" etc etc
Why not ?
$number = 25.54864869;
echo floor($number); // 25
With only javascript you can do:
Math.floor(25.54864869) //25
This should work with JavaScript
Math.floor(25.54864869) // 25