I am trying to get this loop to out put the key and value from what user selected from drop down list...but can only get loop to display the whole array. email is key and zip is value. plus i need it to display both keys when 55302 is selected by the user.
<?PHP
print("<hr />Print out entire \$_POST array:<br />");
// prints out object in human-readable form
print_r($_POST);
// Create an associative array
$zipOrig = array("email01@fake.com" => "55301",
"email02@fake.com" => "55302",
"email03@fake.com" => "55302",
"email04@fake.com" => "55304",
"email05@fake.com" => "55305");
print("<hr />Print out entire \$zipOrig array:<br />");
print_r($zipOrig);
echo"<hr /><br />";
//$email = $key;
// capture the POST variable and save it to a shorter name: $zip
$zip = $_POST['lstZip'];
echo("debug \$zip is: $zip<br />");
if (isset($zipOrig[$email]))
{
// get the zipCode from the array
//$zipCode = $email[$zip];
//echo("Debug \$zipCode is: $zipCode<br />");
}
foreach ($zipOrig as $email => $zip)
{
// determine what zip is selected using $_POST[]
// compare user input zip code with $zipOrig if match do if statement
//if($zip[$email] == $zipOrig)
//if($lstZip == $email)
//if($lstZip == $zipOrig)
//if($lstzip == $key[zipOrig])
//if($lstZip == $key[zipCode])
//if($lstZip == $key[email])
//if ($zip == '55301')
{
//echo"$email . $zipCode<hr />";
echo"\$zip=: $zip<br />";
echo"\$email=: $email<hr />";
echo "zip is: $zip and the email is: $email <hr />";
}
//else
//{
// echo "Sorry no matching records for: $zip<br />";
//}
}
?>