jdubwelch Posted November 10, 2006 Share Posted November 10, 2006 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? Quote Link to comment Share on other sites More sharing options...
fiddy Posted November 10, 2006 Share Posted November 10, 2006 Please try using... for each Quote Link to comment Share on other sites More sharing options...
btherl Posted November 10, 2006 Share Posted November 10, 2006 You can find it using [code=php:0]$families = array_keys($eventsArray, $i);[/code]That will return an array of all the families who have a reservation on that day. Quote Link to comment Share on other sites More sharing options...
jdubwelch Posted November 10, 2006 Author Share Posted November 10, 2006 thanks...i tried array_flip too and that worked, but your way is better. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.