I would like to replicate this site's glossary function: https://www.mortgageloan.com/finance-glossary-terms
Objective: Click on a letter and content corresponding to that letter will be shown. Click on another letter, and only the clicked letter's content is shown.
I have my dictionary.php file with an array setup like this:
$dictionary = array(
'A'=>array(
'Term1'=>'Definition1',
'Term2'=>'Definition2',
),
'B'=>array(
'Term1'=>'Definition1',
'Term2'=>'Definition2',
),
);
I can display the Terms and Definitions fine with a foreach loop, but it displays all the terms and definitions. How can I display the terms and definitions pertaining to only their corresponding letters when the user clicks on that letter?