fork download
  1. <?php
  2. function punyaHuruf($kataPertama, $kataKedua) {
  3. $kataPertama = strtolower($kataPertama);
  4. $kataKedua = strtolower($kataKedua);
  5.  
  6. for ($i = 0; $i < strlen($kataPertama); $i++) {
  7. $huruf = $kataPertama[$i];
  8.  
  9. if (strpos($kata2, $huruf) === false) {
  10. return false;
  11. }
  12. }
  13.  
  14. return true;
  15. }
  16.  
  17. echo punyaHuruf("cat", "antarctica");
  18. echo punyaHuruf("cat", "australia");
  19. echo punyaHuruf("cat", "ANTARCTICA");
  20. ?>
  21.  
Success #stdin #stdout #stderr 0.03s 26216KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Notice:  Undefined variable: kata2 in /home/8LLxHG/prog.php on line 9
PHP Notice:  Undefined variable: kata2 in /home/8LLxHG/prog.php on line 9
PHP Notice:  Undefined variable: kata2 in /home/8LLxHG/prog.php on line 9