Exercice 5-2 - 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 Exercice 5-2.php

  1. <?php
  2. function exercice5(array $tab, string $mot) {
  3.     $chech = 0;
  4.     
  5.     foreach ($tab as $t)
  6.     {
  7.         if ($t == $mot)
  8.         {
  9.             return;
  10.         }
  11.     }
  12.     return false;
  13. }
  14.  
  15. $trouve = exercice5(["paul", "Axel", "Wael"], "Pascal");
  16.  
  17. if ($trouve)
  18. {
  19.     echo "trouvé\n"
  20. }
  21.  
  22. else
  23. {
  24.     echo "manquant\n"
  25. }
File Description
  • Exercice 5-2
  • PHP Code
  • 21 Oct-2021
  • 323 Bytes
You can Share it: