pr5 - 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 pr5.php
- <?php
- error_reporting(-1);
- /*
- $rates = array(3, 5, 3, 2, 1, 8, 4, 3, 4, 3, 2, 3);
- $ratesSum = array_sum($rates);
- $ratesCount = count($rates);
- $averageRate = array_sum($rates)/count($rates);
- echo "Анону поставили {$ratesCount} оценок, их сумма = {$ratesSum}\nСредний балл — {$averageRate}\n";
- $anonHeight = 169;
- $classmates = array(
- 'Антон' => 172,
- 'Семен' => 165,
- 'Лена' => 189,
- 'Иван' => 171,
- 'Петр' => 182,
- 'Сидор' => 176,
- 'Аня' => 180,
- 'Таня' => 179,
- 'Маня' => 171
- );
- $number = 0;
- foreach ($classmates as $name => $height) {
- if ($anonHeight<$height){
- $number+=1;
- }
- echo "Имя: {$name}, рост: {$height} см.\n";
- }
- echo "В классе {$number} человек выше анона\n";*/
- /*$answers = array(
- 1 => 'да',
- 2 => 'нет',
- 3 => 'не знаю',
- 4 => 'никогда',
- 5 => 'это зависит от тебя',
- 6 => 'спроси анона'
- );
- $question = 'Выучу ли я PHP без регистрации и СМС?';
- $a=array_rand($answers);
- echo "Вопрос: {$question}\n";
- echo "Ответ: {$answers[$a]}\n";*/
- /*$letters = array(
- 'ко', 'и', 'дзу', 'ми',
- 'са', 'ку', 'ра', 'да',
- 'чи', 'а', 'ки', 'ми',
- 'на', 'го', 'ха', 'ру'
- );
- $name = '';
- for ($i = 1; $i <= 4; $i++) {
- $random = array_rand($letters);
- $randomText = $letters[$random];
- echo "Выпало число {$random}, слог {$randomText}\n";
- $name= $randomText . $name;
- }
- echo "------\n";
- echo "Советую имя: {$name} - не прогадаешь!\n";*/