fork download
  1. <?php
  2.  
  3. $text = "This is some text. This is some text. Vending Machines are great.Баста - ЧК (Чистый Кайф)";
  4. $string = preg_replace('/[^\p{L}\p{N}\s]/u', ' ', $text);
  5. $string = preg_replace('/\s+/', ' ', $string);
  6. $string = mb_strtolower($string, 'UTF-8');
  7. $keywords = explode(' ', trim($string));
  8. var_dump($keywords);
Success #stdin #stdout 0.02s 52480KB
stdin
Standard input is empty
stdout
array(16) {
  [0]=>
  string(4) "this"
  [1]=>
  string(2) "is"
  [2]=>
  string(4) "some"
  [3]=>
  string(4) "text"
  [4]=>
  string(4) "this"
  [5]=>
  string(2) "is"
  [6]=>
  string(4) "some"
  [7]=>
  string(4) "text"
  [8]=>
  string(7) "vending"
  [9]=>
  string(8) "machines"
  [10]=>
  string(3) "are"
  [11]=>
  string(5) "great"
  [12]=>
  string(10) "баста"
  [13]=>
  string(4) "чк"
  [14]=>
  string(12) "чистый"
  [15]=>
  string(8) "кайф"
}