只选择一个字母

The script below is showing me a list of all my shops and it's ordering it in alphabetical order. Now I want to put, for example $_GET['letter'] == "A"; that it will show me only the stores that begin with the letter A.

How can I do that?

$stores = get_terms(APP_TAX_STORE, array('hide_empty' => 0, 'parent' => 0));
$list = '';
$groups = array();

// get ids of all hidden stores 
$hidden_stores_query = "SELECT ". $wpdb->prefix ."clpr_storesmeta.stores_id FROM ". $wpdb->prefix ."clpr_storesmeta WHERE ". $wpdb->prefix ."clpr_storesmeta.meta_key = 'clpr_store_active' AND ". $wpdb->prefix ."clpr_storesmeta.meta_value = 'no'";
$hidden_stores = $wpdb->get_col($hidden_stores_query);

if ($stores && is_array($stores) ) {

    foreach($stores as $store)
        $groups[strtoupper($store->name[0])][] = $store;
    if (!empty($groups)) :
        foreach($groups as $letter => $stores) {
      $old_list = $list;

      $letter_items = false;
            $list .= "
\t" . '<h2 class="stores" id="' . apply_filters( 'the_title', $letter ) . '">' . apply_filters( 'the_title', $letter ) . '</h2>';
            $list .= "
\t" . '<ul class="stores">';

            foreach($stores as $store) {
                if (!in_array($store->term_id, $hidden_stores)) {
                    $list .= "
\t\t" . '<li><a href="' . get_term_link($store, APP_TAX_STORE) . '"><img src="/images/korting-winkels/'. ereg_replace("[^A-Za-z0-9]", "", strtolower(apply_filters('the_title', $store->name))).'.png" width="133" class="afbeelding" height="68" alt="' . apply_filters('the_title', $store->name). '" title="' . apply_filters('the_title', $store->name). '" /></a><br /></li>';
          $letter_items = true;
        }
            }   

            $list .= "
\t" . '</ul>';

      if(!$letter_items)
        $list = $old_list;
        }

    endif;

} else {

    $list .= "
\t" . '<p>' . __('Sorry, but no stores were found.', 'appthemes') .'</p>';

}

You'd be better to put this in your query (so you aren't pulling out data which isn't required on the page), something like:

SELECT * FROM `table` WHERE `name` LIKE '$startLetter%'

I assume this is handled by your get_terms function, without seeing that I can't really give more specifics.

you can select from database or if you don't want to do that you can do ,

$list = array("abc","abd","xyz","aml");//assuming this is your array
foreach($list as $listValue){
    if(substr($listValue, 0 ,1) == "a"){ //instead of "a" put $_GET['letter']
        $finalarray[] = $listValue;
    }
}

//in $finalarray you will have only data which is starting with a($_GET['letter'])