Dillion & Amanda 4 Lif Posted June 7, 2010 Share Posted June 7, 2010 <?php function divide($val1,$val2){ $res = round($val1 / $val2); if(fmod($val1,$val2) > 0){ $res .= '<sup>r'.fmod($val1,$val2).'</sup>'; } return number_format($res); } echo divide(100,5); // Returns 20 echo divide(100,7); // Returns 14 and a small 2 in the right hand corner. ?> Just figured this would help people out with getting full division done. Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted June 7, 2010 Share Posted June 7, 2010 Now this is fun since i did avgval people have done some functions, Good on you guys it's always good to submit them to the notes on php.net also. Quote Link to comment Share on other sites More sharing options...
Karlos94 Posted June 8, 2010 Share Posted June 8, 2010 There is one problem, the way you have formatted it your making it looking powers.. I'd recommend having a look and rethinking how to display it. Quote Link to comment Share on other sites More sharing options...
Dillion & Amanda 4 Lif Posted June 8, 2010 Author Share Posted June 8, 2010 There is one problem, the way you have formatted it your making it looking powers.. I'd recommend having a look and rethinking how to display it. Fine. I added an "r" next to the remainder. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.