Login   Register  
PHP Classes
elePHPant
Icontem

File: example/suggest.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Cesar D. Rodas  >  Autocomplete  >  example/suggest.php  >  Download  
File: example/suggest.php
Role: Example script
Content type: text/plain
Description: First commit
Class: Autocomplete
Suggest words to complete search using edge n-gram
Author: By
Last change:
Date: 1 year ago
Size: 356 bytes
 

Contents

Class file image Download
<?php

require __DIR__ "/../vendor/autoload.php";

use 
crodas\Autocomplete\Autocomplete;
use 
crodas\Autocomplete\PDOConn;

$pdo     = new PDO("sqlite:data.db");
$conn    = new PDOConn($pdo);
$suggest = new Autocomplete($conn);

$words = [];
foreach (
$suggest->suggest($_GET['term']) as $word) {
    
$words[] = $word['word'];
}

echo 
json_encode($words);