Func - 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 Func.php

  1. <?php
  2. function searchPopularWords(string $text) 
  3. {
  4.     $result = [];
  5.     $words = explode(' ', $text);
  6.     foreach($words as $word) {
  7.         if (isset($result[$word])) {
  8.             $result[$word] = $result[$word]+1;
  9.             continue;
  10.         }
  11.         $result[$word] = 1;
  12.     }
  13.     return $result;
  14. };
  15. $text = 'word word word word';
  16. var_export(searchPopularWords($text));
File Description
  • Func
  • PHP Code
  • 14 Dec-2020
  • 376 Bytes
You can Share it: