If you divide something in PHP, it gives you decimals. Is there a way so that you can use the remainder insead? for example, instead of 100/33 = 3.3333 etc, it would equal 3 remainder 1

    Well you can do it with two operations. The first being the division followed by number format to remove everything after the decimal. Then use the "%" operator to get the remainder.

      will this work:

      $v = $numa / $numb;
      $b = $numa % $numb;

      $u = $b + $numb;
      $newv = $numa / $u;

      echo "The answer is $newv remainder $b";

        Ok, I kinda got it to work, just a little tweaking to do. This is what I have:

        elseif($operator == '/r')
            {
            $b = $numa % $numb;
            $u = $numa - $b;
            $v = "$u / $numab";
        
        echo "The answer is $v remainder $b";
        
        }

        now lets say $numa = 10 and $numb = 3, then I will get something like:

        The answer is 9 / remainder 1

        so, i remove the "in the $v equation and I get a "Cannot divide by 0". how can I get rid of the / after the 9?

          does it have to do with the php version or my code?

            Write a Reply...