123 - 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.
Result of php executing
Full code of 123.php
- <?php
- $a = [4, 2, 4, 6, 1, 7];
- $b = [2, 1, 8, 5];
- $fot = 11;
- $currentFot = 0;
- $i = 0;
- if (count($a) > count($b)) {
- $arrLen = count($a);
- } else {
- $arrLen = count($b);
- }
- for ($i = 0; $i < $arrLen; $i++ ) {
- if (isset($a[$i]) and isset($b[$i])) {
- if ($a[$i] > $b[$i]) {
- $currentFot += $b[$i];
- }
- } elseif (isset($a[$i])) {
- $currentFot += $a[$i];
- } else {
- $currentFot += $b[$i];
- }
- if ($currentFot >= $fot) {
- break;
- }
- }
- echo $i-1;