Mariush - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Mariush.php

  1. <?php
  2.  
  3. const LIMIT = 100;
  4.  
  5. $a = ['a' => 10, 'b' => 20, 'c' => 30, 'd' => 45, 'e' => 50, 'f' => 12];
  6.  
  7. $sum = 0;
  8. foreach ($a as $k => $v) {
  9.     if ($v >= LIMIT - $sum) {
  10.         $a[$k] = max(LIMIT - $sum, 0);
  11.     }
  12.     $sum += $v;
  13. }
  14.  
  15. var_dump($a);
File Description
  • Mariush
  • PHP Code
  • 21 Jun-2018
  • 245 Bytes
You can Share it: