javascript - How to remove blank array from autocomplete data? -
i trying remove blank array autocomplete data.i mean how delete or remove blank array autocomplete output list?
$(function() { var available_tags=[ <?php foreach(glob('../image/imagefiles/*.*') $key=>$filename){ if($key==0) {echo "'".$filename."'";} else {echo ",'".$filename."'";} } ?> ]; $( "#tags" ).autocomplete({ minlength: 0, source: available_tags, }); }); <div class="ui-widget"> <input id="tags" size="50"> </div> output :
.
..
image1
image2
need output :
image1
image2
to remove 2 references . , .. (those entries not blank, references current , parent directory) in listing returned call glob() can ignore them when iterating on result:
<?php $elements = array(); foreach(glob('../image/imagefiles/*.*') $key=>$filename) { if(!in_array($filename, array('.', '..'))) { $elements[] = "'".$filename."'"; } } echo implode(',', $elements); you want add html markup in there , htmlescape() file names, snippet should point out how skip entries...
Comments
Post a Comment