I have a drop-down of location/Region, inside that there is a search box.
As shown in the image, there is a list of places, and then there are regions. The section of region is static and the rest of the places is being fetched from the database. Inside the search box i am able to search for regions but not for dynamic data. One option can be to use DB query but is there a way to perform this functionality without a DB query.
For search, I want each string should match. If user's first letter in search box is "w" then words starting from w should get displayed and not those words who have letter 'w'
<select class="selectpicker select-custom-field location" data-live-search="true" data-live-search-style="begins" title="Location/Region">
    <?php foreach($city as $per_city): ?>
        <option value="<?php echo $per_city->city.','.$per_city->state; ?>">
            <?php echo $per_city->city.', '.$per_city->state; ?>
        </option>
    <?php endforeach; ?>
        <option value="Regions">Regions</option>
        <option value="WEST">WEST</option>
        <option value="SOUTHWEST">SOUTHWEST</option>
        <option value="MIDWEST">MIDWEST</option>
        <option value="SOUTHEAST">SOUTHEAST</option>
        <option value="NORTHEAST">NORTHEAST</option>
</select>
Sample array that i get from $city is
Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [city] => Rochester
            [state] => New York
            [country] => 
        )
    [1] => stdClass Object
        (
            [id] => 2
            [city] => Richmond
            [state] => Virginia
            [country] => 
        )
    [2] => stdClass Object
        (
            [id] => 3
            [city] => Spokane
            [state] => Washington
            [country] => 
        )
    [3] => stdClass Object
        (
            [id] => 4
            [city] => Des Moines
            [state] => Iowa
            [country] => 
        )
)
Can anyone please tell how this can be done
Note: If I remove data-live-search-style="begins" from select tag then the search is occuring but the in that search, if user's first letter is "w" then all the words that contain "w" are getting displayed.
