joomla - Calculations In PHP -


i needing perform calculation , round results in php. have tried below end 0. if manually perform calculation should not case. below syntax , after is

val1-val2 answer above / val1 answer above * 100 (to percent) 

here syntax use

print "<td>" . number_format(round($res->val1-$res->val2/$res->val1)*100) . "%" . "</td>"; 

edit
let's use real life example $val1 = 1122 $val2 = 280

i want calculation steps $val1-$val2 = 842
then 842/$val1 or 842/1122 = .75

if use ($val1-$val2)/$val1 = 1 incorrect.

echo round((($val1 - $val2) / $val1) * 100).'%'; 

works fine? see here https://3v4l.org/d4bpe


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -