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
- for ($hours = 1; $hours <= 24; $hours++) {
- echo "Часов: $hours, Стоимость: " . getBodyguardPrice($hours) . "₽\n";
- }
- function getBodyguardPrice($hoursCount)
- {
- if ($hoursCount == 1) {
- return 5000;
- }
- if ($hoursCount == 2) {
- return 8000;
- }
- if ($hoursCount == 3) {
- return 9000;
- }
- if ($hoursCount < 6) {
- return 9000 + ($hoursCount - 3) * 2500;
- }
- if ($hoursCount == 6) {
- return 15000;
- }
- if ($hoursCount < 10) {
- return 15000 + ($hoursCount - 6) * 2000;
- }
- if ($hoursCount == 10) {
- return 20000;
- }
- if ($hoursCount < 14) {
- return 20000 + ($hoursCount - 10) * 1500;
- }
- if ($hoursCount == 14) {
- return 21000;
- }
- if ($hoursCount < 18) {
- return 21000 + ($hoursCount - 14) * 1300;
- }
- if ($hoursCount == 18) {
- return 23400;
- }
- if ($hoursCount < 24) {
- return 23400 + ($hoursCount - 18) * 1200;
- }
- if ($hoursCount == 24) {
- return 28800;
- }
- return 28800 + ($hoursCount - 24) * 1000;
- }