Can someone help, don’t know how to solve this using loop in php.
$pay = [20, 40 , 89, 300, 190, 15]; $Capital = 1000; I want the loop to achieve this result 1000-20 = 980 980-40 = 940 940-89 = 851 851-300 = 551 551-190 = 361 361-15 = 346 My code is: $newbal = $Capital-$pay for ($amount=$newbal; $amount>=$Capital; $amount-=$pay) { echo "{$amount}"; $amount++; } My code is giving me this result: 1000-20 = 980 1000-40 = 960 1000-89 = 911 1000-300 = 700 1000-190 = 810 1000-15 = 985
foreach ($pay as $val) { $Capital -= $val; echo "Capital value: $Capital\n"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)