foreach ($array as $key=>$element) { if (your_condition) echo("{$array2[$key]} $element"); } this is a general solution, but in your case why do you need to use the array with lastname as the element, why not just test the keys of the first name array, i.e. foreach ($array2 as $key=>$element) { if (your_condition) echo("$key $element"); } ... and why do you have the 2 arrays in the first place? Tim Ward Senior Systems Engineer Please refer to the following disclaimer in respect of this message: http://www.stivesdirect.com/e-mail-disclaimer.html > -----Original Message----- > From: Kevin Price-Ward [mailto:[EMAIL PROTECTED]] > Sent: 17 July 2001 11:24 > To: [EMAIL PROTECTED] > Subject: Extracting from arrays - alphabetically > > > Hi, > > A simple problem for you guys (I think), > > I have 2 arrays - firstname and lastname, both have the same > associative > index - lastname, I have then performed asort on both to order them > alphabetically. Now I just need to extract and display the > array elements > that have the associative index beginning with A or B or > whatever is defined > by $query - thus displaying only names where the lastname > begins with A etc. > > How do I do this? > > Thanks for any help you can offer. > > Lar > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]