Divide integer number into 3 parts using php -
i need divide integer value 3 parts using php
for eg: have value 9 answer 3 + 3 + 3 if have value 10 ans 3 + 3 + 4 or that
you can use modulus function.
<?php $yourint=10; $remainder=$yourint % 3; $third=floor($yourint/3); $lastbit=$third+$remainder; echo "the numbers $third + $third + $lastbit."; ?>
output:
the numbers 3 + 3 + 4.
Comments
Post a Comment