$( "#autocomplete" ).autocomplete({
source: [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby" ]
}); // this is the simple version. LOOK TO THE UPDATE!!!
这是我的 JQuery 代码。
问题:如何使用 PHP 创建编程语言的向量!?
更新:
jQuery
var keys = null; // HERE I NEED THE ARRAY, ANY ARRAY GENERATED USING PHP
$("#word").autocomplete({
source: function(req, response) {
var re = $.ui.autocomplete.escapeRegex(req.term);
var matcher = new RegExp( "^" + re, "i" );
response($.grep( keys, function(item){
return matcher.test(item); }) );
},
minLength: 2,
select: function(event, ui) {
$('#word').val(ui.item);
}
});
html
<form method="POST" name="search" action="">
<label for="autocomplete">Im looking for:</label>
<input type="text" id="word" name="word" />
<input type="hidden" id="word_id" name="word_id" />
</form>
php
for($i = 1; $i < $total_rows; ++$i)
{
$sample_return[] = array("id"=>$i,"label"=>$ar1[$i],"value"=>$ar2[$i]);
}