Skip to content

Instantly share code, notes, and snippets.

@rogerdudler
Created March 25, 2011 10:36
Show Gist options
  • Save rogerdudler/886666 to your computer and use it in GitHub Desktop.
Save rogerdudler/886666 to your computer and use it in GitHub Desktop.
<?php
$q = $_REQUEST['q'];
$commands = array('create', 'delete', 'insert', 'help', 'select');
$response = array();
$length = strlen($q);
while(list($key, $proposal) = each($commands)) {
if (strtolower($q) == strtolower(substr($proposal, 0, $length))) {
$response['suggestion'] = $proposal;
break;
}
}
echo json_encode($response);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment