Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RandomWordSelector.php
Go to the documentation of this file.
1 <?php
7 
12 {
20  public function getRandomWords($source, $count)
21  {
22  $words = str_word_count($source, 1);
23  if (empty($words)) {
24  return [];
25  }
26 
27  $randWords = [];
28  $wordsSize = count($words);
29  while ($count) {
30  $randWords[] = $words[random_int(0, $wordsSize - 1)];
31  $count--;
32  }
33 
34  return $randWords;
35  }
36 }
$source
Definition: source.php:23
$count
Definition: recent.phtml:13