Array_CZ - 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.



Your result can be seen below.

Result of php executing





Full code of Array_CZ.php

  1. <?php
  2. echo('Zobrazeni zadaneho pole:' . "\n");
  3. $znamky = [1,2,3,4,5];
  4. print_r($znamky);
  5.  
  6. echo('Nacteni do pole rucne a zobrazeni:' ."\n");
  7. $znamky2 = [];
  8. $znamky2[] = 1;
  9. $znamky2[] = 2;
  10. $znamky2[] = 3;
  11. $znamky2[] = 4;
  12. $znamky2[] = 5;
  13. print_r($znamky2);
  14.  
  15.  
  16. echo('Nacteni do pole pomoci cyklu a zobrazeni pole mimo cyklus:' . "\n");
  17. $znamky3 = [];
  18. for($i=0;$i<=5;$i++)
  19. {
  20.     $znamky3[$i] = $i+1;
  21. }
  22. print_r($znamky3);
  23.  
  24. echo('Zobrazeni pole pomoci cyklu:' . "\n");
  25. for($x=1;$x<6;$x++)
  26. {
  27.     echo($x . '. znamka v poli je ' . $znamky[$x-1] . "\n");
  28. }
  29.  
  30. echo('Vypocet prumeru ze znamek v poli:' . "\n");
  31. $mojeZnamky = [2, 4, 3, 1, 2, 1, 1, 5];
  32. $prumer = array_sum($mojeZnamky) / count($mojeZnamky);
  33. echo("\nMuj prumer je: " . $prumer);
  34.  
  35. echo("Ceske datum \n");
  36. $mesice = array('leden', 'unor', 'brezen', 'duben', 'kveten',
  37.       'cerven', 'cervenec', 'srpen', 'zari', 'rijen', 'listopad', 'prosinec');
  38. $den = date('j');
  39. $mesic = date('m');
  40. $mesicSlovy = $mesice[$mesic-1];
  41. $rok = date('Y');
  42. echo("\nDnes je $den$mesicSlovy $rok");
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. ?>
  59.  
File Description
  • Array_CZ
  • PHP Code
  • 16 Oct-2018
  • 1.02 Kb
You can Share it: