<?php /* determine the difference between the user supplied string and the one in the database based on the contained characters */ function char_compare($db_str, $user_str) { return similar_text($db_str, $user_str); } $db = new SQLiteDatabase("server-php-sqlite-demo.db"); /* Create char_compare() function inside SQLite based on our PHP function, char_compare(). The 3rd parameter indicates how many arguments the function requires */ $db->createFunction('char_compare', 'char_compare', 2); /* Execute query, where char_compare() is used to perform the string comparison between name & specified string */ $res = $db->arrayQuery("SELECT name, char_compare(name, 'Il2') AS sim_index FROM foo", SQLITE_ASSOC); print_r($res); ?>