This is pretty silly and I should definitely know this by now; in fact, I'm ashamed of myself.
<?php
$genders = array(
'Female' => 'f',
'Male' => 'm'
);
$gender = 'f';
foreach ($genders as $k=>$v) {
if ($gender == $v) {
echo $genders[$k];
}
}
?>
This echoes 'f'. I want the key, not the value. I want it to echo 'Female'. What am I missing here?
Thanks in advance!