$encoding) { if (stripos($encoding, $string) !== 0) { continue; } $matches[$prefix . $encoding] = check_plain($encoding); // Remove matches so we don't search them again. unset($encodings[$delta]); } // Find contains next. foreach ($encodings as $encoding) { if (stripos($encoding, $string) !== FALSE) { $matches[$prefix . $encoding] = check_plain($encoding); } } // Only send back 10 suggestions. $matches = array_slice($matches, 0, 10, TRUE); drupal_json_output($matches); }