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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.