Skip to content

Instantly share code, notes, and snippets.

@geggleto
Created November 18, 2015 14:12
Show Gist options
  • Select an option

  • Save geggleto/dd076d71f3c01875d92e to your computer and use it in GitHub Desktop.

Select an option

Save geggleto/dd076d71f3c01875d92e to your computer and use it in GitHub Desktop.
production code atm
function ew_GetKeyword(&$src, &$kwlist, &$x, &$y, &$kw) {
$thisy = -1;
$thiskw = "";
foreach ($kwlist as $wrkkw) {
$wrkkw = trim($wrkkw);
if (EW_HIGHLIGHT_COMPARE) { // Case-insensitive
if (function_exists('stripos')) { // PHP 5
$wrky = stripos($src, $wrkkw, $x);
} else {
$wrky = strpos(strtoupper($src), strtoupper($wrkkw), $x);
}
} else {
$wrky = strpos($src, $wrkkw, $x);
}
if ($wrky !== FALSE) {
if ($thisy == -1) {
$thisy = $wrky;
$thiskw = $wrkkw;
} elseif ($wrky < $thisy) {
$thisy = $wrky;
$thiskw = $wrkkw;
}
}
}
$y = $thisy;
$kw = $thiskw;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment