Finding Zodiac with Three-dimensional Array
Hey, this is my first post on this site and IT'S A QUESTION! Right now, I'm taking a PHP server scripting class at my university and am working on a Chinese Zodiac website project. It's pretty easy and fun, and one of the pages has to take in user input for their birth date and then use a PHP function to determine their zodiac, which I made. I just wanted to go an extra mile, so I created a three-dimensional array where each animal has their own sub-dimensional arrays for a start and end date. What I'm trying to do is take the user's input and loop through the arrays to find where their birth date is between the same indices of the start and end date arrays, and then return the parent animal array name. I can't figure out how to do this because I have never actually worked with multidimensional array before, so I'm still wrapping my head around this. Here's a code snippet and if anyone could help me, I'd appreciate it. So if the user enter the date of October 25th 1912, it would go through all animals and then match the date, and return 'Rat' as the sign; at least that's what I want it to do. <?php $birthYear='1912-10-25'; $findSign=''; echo "Your zodiac sign is ".$findSign."."; function findZodiac($birthYear) { $zSigns=array ( $rat=array( $startDate=array('1912-02-18', '1924-02-05', '1936-01-24', '1948-02-10', '1960-01-28', '1972-02-15', '1984-02-02', '1996-02-19', '2008-02-06', '2020-01-25', '2032-02-11', '2044-01-30'), $endDate=array('1913-02-05', '1925-01-23', '1936-02-10', '1949-01-28', '1961-02-14', '1973-02-02', '1985-02-19', '1997-02-06', '2009-01-25', '2021-02-11', '2033-01-30', '2045-02-16') ), $ox=array( $startDate=array(...), $endDate=array(...) ) ); if($zYear>=t_foreach($zSigns[0][0]) && $zYear<=t_foreach($zSings[0][1])) {$findSign=$zSigns[0];} return $findSign;