Jump to content

getting the name of the key


jdubwelch

Recommended Posts

i have an array in the format:

[family] => day that they have a reservation

[code]eventsArray
(
    [Jason & Deena] => 29
    [Bob & Krista] => 9
    [Marolyn] => 15
    [J&D] => 17
    [bob & sally] => 22
    [Bob & Sally] => 25
)[/code]

I want to search throught the array and if there is an event on that day, print the key for it.  In this case the key is the name of the family.

[code]for ($i=1; $i<=31; $i++) {

if (in_array($i, $eventsArray)) {
echo "yes, there is an event on $i<br>";
}
}[/code]

how do i get the name of the key that has the value $i?



Link to comment
https://forums.phpfreaks.com/topic/26795-getting-the-name-of-the-key/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.