Calculate zodiac signs

WBOY
Release: 2016-07-25 08:50:23
Original
1483 people have browsed it
  1. /**
  2. * Calculation. Zodiac
  3. *
  4. * @param int $year Year
  5. * @return str
  6. */
  7. function get_animal($year){
  8. $animals = array(
  9. 'Rat', 'Ox', 'Tiger', 'Rabbit', 'Dragon ', 'Snake',
  10. 'Horse', 'Sheep', 'Monkey', 'Chicken', 'Dog', 'Pig'
  11. );
  12. $key = ($year - 1900) % 12;
  13. return $animals [$key];
  14. }
  15. echo get_animal(1990); // Horse
  16. echo get_animal(2010); // Tiger
Copy code


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!