title: How to get most important occurrences from an array?
body: <p>First of all, this is not a language specific question, the below example uses PHP but it's more about the method (regex?) to find the answer.</p>
  
  <p>Let's say I have an array:</p>
  
  <pre><code>$array = ['The Bert and Ernie game', 'The Bert &amp; Ernie game', 'Bert and Ernie game', 'Bert and Ernie game - english version', 'Bert &amp; Ernie (game)', 'Bert and Ernie - game'] etc...
  </code></pre>
  
  <p>I want to fetch a combination that shows the most important combinations. So I want to do:</p>
  
  <pre><code>$magicPattern = [something that renders most important occurrences];
  preg_match($magicPattern, $array, $matches);
  print_r($matches);
  </code></pre>
  
  <p>As an output I would like to receive something like: "Bert and Ernie game"</p>
  
  <p>PS:
  I'm not necessary looking for an actual array, a concept to do this would be great too.</p>
  
  <p><strong>UPDATE:</strong><br>
  Current code below, any thoughts if this would be a good way of finding the best version of an occurrence? Having a hard time figuring it out from the <a href="https://github.com/php/php-src/blob/PHP-5.6.10/ext/standard/levenshtein.c" rel="nofollow">source</a> of the function.</p>
  
  <pre><code>$array['The Bert and Ernie game']               =0; //lev distance
  $array['The Bert &amp; Ernie game']                 =0; //lev distance
  $array['Bert and Ernie game']                   =0; //lev distance
  $array['Bert and Ernie game - english version'] =0; //lev distance
  $array['Bert &amp; Ernie (game)']                   =0; //lev distance
  $array['Bert and Ernie - game']                 =0; //lev distance
  
  foreach($array as $currentKey =&gt; $currentVal){
      foreach($array as $matchKey =&gt; $matchVal){
          $array[$currentKey] += levenshtein($currentKey, $matchKey);
      }
  }
  
  $array = array_flip($array);
  ksort($array);
  
  echo array_values($array)[0]; //Bert and Ernie game
  </code></pre>