I am making a small script with javascript to find/display text from an array as I am typing. Sort of like, Google auto suggest tool.
Here is Js script:
<script>
$(function() {
var availableTags = <?php echo json_encode( $foo ); ?>;
$( "#tags" ).autocomplete({ source: availableTags });
});
</script>
and the arrays in PHP
<?php
$foo = array("ambiguious","brown",
"corps","demanding job","eat the pomes","fooling with it");
?>
Notice how each words in the array have different first letters than the rest ie.? good, now when I type a instead of showing words that being with a (in this case "ambiguious"), it shows me all words which has a in them.
I thought about making strpos()
to search through similar words, but it does not work.
Any thoughts would be nice. Thank you.