are trying to get this?
$alphabets = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
$letter = array("Ahahah", "Bwahahah", "Ahow", "Catcw"); // is this what letters value?
foreach ($alphabets as $alphabet) {
echo $alphabet;
$match = null;
foreach($letter as $let){
preg_match("/[$alphabet]?/is", $let, $match);
if(isset($match[0]) && $match[0]){
echo '<a href="#letter-'.$alphabet.'">'.$let.'</a> ';
}
}
}
result: A Ahahaha Ahow B Bwahahah C Catcw