<?php $balance = 10000; // баланс игрока $many_sek = 1000; // доход игрока в секунду ?> <div style='display: none;visibility: hidden;'id="elem"></div><br> ваш баланс:<div id="elem2"><?php echo $balance; ?></div><br> доход в секунду: 1к <script language="JavaScript"> function abbreviateNumber(value) { var newValue = value; if (value >= 1000) { var suffixes = ['','k','m','b','t','q','u','x','y','h','s','d','v','w','r','g','n','c','p','o','z','vi','un','du','tr','qu','qi','se','sp','oc','nv','tn','ut','dt','aa','ab','ac','ad','ae','af','ag','ah','ai','aj','ak','al','am','an','ao','ap','aq','ar','as','at','au','av','aw','ax','ay','az','limit','limit','limit']; var suffixNum = Math.floor( (""+value).length/3 ); var shortValue = ''; for (var precision = 2; precision >= 1; precision--) { shortValue = parseFloat( (suffixNum != 0 ? (value / Math.pow(1000,suffixNum) ) : value).toPrecision(precision)); var dotLessShortValue = (shortValue + '').replace(/[^a-zA-Z 0-9]+/g,''); if (dotLessShortValue.length <= 2) { break; } } if (shortValue % 1 != 0) shortNum = shortValue.toFixed(1); newValue = shortValue+suffixes[suffixNum]; } return newValue; } window.onload = function () { let param2 = '<?php echo $balance; ?>'; let param1 = '<?php echo $many_sek; ?>'; let div = document.getElementById('elem'); let div2 = document.getElementById('elem2'); div.value = param2; function time() { let val = +div.value; console.log(val); let result2 = abbreviateNumber(val + +param1); div2.value = result2; div2.innerText = result2; let result = val + +param1; div.value = result; div.innerText = result; } setInterval(time,1000); } </script>