protected Container::getAlternatives($search_key, array $keys)
Provides alternatives for a given array and key.
string $search_key: The search key to get alternatives for.
array $keys: The search space to search for alternatives in.
string[] An array of strings with suitable alternatives.
protected function getAlternatives($search_key, array $keys) { $alternatives = array(); foreach ($keys as $key) { $lev = levenshtein($search_key, $key); if ($lev <= strlen($search_key) / 3 || strpos($key, $search_key) !== FALSE) { $alternatives[] = $key; } } return $alternatives; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!DependencyInjection!Container.php/function/Container::getAlternatives/8.1.x