Skip to content

Instantly share code, notes, and snippets.

Last active Apr 18, 2022
What would you like to do?
$term = $_GET['term'];
$r = new Redis("","6379");
$items = $r->zrangebylex("kernel","[$term","[$term\xff",Array("LIMIT","0","10"));
$t = Array();
$id = 0;
foreach($items as $item) {
$t[] = Array("id" => $id++, "label" => $item);
$json = new Services_JSON();
$output = $json->encode($t);
Copy link

ghost commented Jul 14, 2014

Warning: fsockopen() [For instance many configuration options can be modified without any kind of restart using the function.fsockopen]: unable to connect to (Connection refused) in /var/virtual/ on line 29

Fatal error: Cannot open socket to, error 111. in /var/virtual/ on line 37

Copy link

ThreadedThinking commented Aug 26, 2014

I am unsure how this works as I cannot find support for zrangebylex with PHP anywhere.

Copy link

milovtim commented May 30, 2016

Seems like demo script doesn't work for several years :-(

Copy link

al-ramadhan commented Jun 16, 2016

You can use predis library and call ZSetRangeByLex

Copy link

mictadlo commented Aug 19, 2019

By any chance has anyone an example project on how to store the data, index it and the UI for autocomplete?

Thank you in advance.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment