checkPrice - 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 checkPrice.php
- <?php
- $total = 75;
- $free = 25;
- $paid = 10;
- $price = 25;
- //===================
- $unpaid = max( $total - ($paid + $free), 0);
- if($total <= $free) {
- $toPay = 0;
- }
- else if($total > $free && $total <= 100) {
- if($paid > $price) {
- $toPay = 0;
- } else {
- $toPay = $price;
- }
- }
- else {
- if($paid < 100) {
- $toPay = (ceil( ($unpaid - 100) / 50) + 1) * $price ;
- } else {
- $toPay = (ceil( $unpaid / 50 ) ) * $price;
- }
- }
- print_r( ['total' => $total, 'paid' => $paid, 'unpaid' => $unpaid, 'toPay' => $toPay] );
File Description
- checkPrice
- PHP Code
- 04 Feb-2021
- 553 Bytes
You can Share it:
Latest PHP Pastes