Php obtains information about the constellation and Zodiac Based on the date or time stamp.

Source: Internet
Author: User
This article describes how to obtain information about the constellation and Zodiac using the date or timestamp in php. For more information, see

This article describes how to obtain information about the constellation and Zodiac using the date or timestamp in php. For more information, see

This article describes a function that uses php to obtain information about the calendar year, zodiac signs, and Zodiac signs based on the date or time stamp. The specific function code and usage are as follows:

/** Determine Ganzhi, Zodiac, and constellation */function birthext ($ birth) {if (strstr ($ birth ,'-') ===false & strlen ($ birth )! = 8) {$ birth = date ("Y-m-d", $ birth);} if (strlen ($ birth) = 8) {if (eregi ('([0-9] {4}) ([0-9] {2}) ([0-9] {2}) $ ', $ birth, $ bir) $ birth = "{$ bir [1]}-{$ bir [2]}-{$ bir [3]}";} if (strlen ($ birth) <8) {return false;} $ tmpstr = explode ('-', $ birth); if (count ($ tmpstr )! = 3) {return false;} $ y = (int) $ tmpstr [0]; $ m = (int) $ tmpstr [1]; $ d = (int) $ tmpstr [2]; $ result = array (); $ xzdict = array ('capricorn ', 'aquarius', 'pisces ', 'aries', 'taurus ', 'gemine', 'cancer ', 'lions', 'virgins ', 'libra', 'scorpio ', 'sagittarius'); $ zone = array (1222,122,222,321,421,522,622,722,822,922,102, 1222 ); if (100 * $ m + $ d) >=$ zone [0] | (100 * $ m + $ d) <$ zone [1]) {$ I = 0;} else {for ($ I = 1; $ I <12; $ I ++) {if (100 * $ m + $ d)> = $ zone [$ I] & (100 * $ m + $ d) <$ zone [$ I + 1]) {break ;}}} $ result ['xz '] = $ xzdict [$ I]. 'seat '; $ gzdict = array ('A',' B ', 'bing', 'ding', 'pente', 'ji', 'geng ', 'sin', 'hire', 'dece'), array ('sub', 'Ugly ', 'yin', 'mao ', 'chen', 'si ', 'wu ', 'wei', 'shen ', 'you', 'haid'); $ I = $ y-1900 + 36; $ result ['gz '] = $ gzdict [0] [($ I % 10)]. $ gzdict [1] [($ I % 12)]; $ sxdict = array ('rat ', 'ox', 'tiger ', 'rabbit', 'Dragon ', 'snake ', 'Ma', 'goat', 'Monkey ', 'chicken', 'dog ', 'pig '); $ result ['sx '] = $ sxdict [($ y-4) % 12)]; return $ result ;}

Example:

<? Php header ("Content-Type: text/html; charset = UTF-8"); echo'

'; $ Arr = birthext ('20140901'); // timestamp print_r ($ arr); $ arr = birthext ('2017-07-08'); print_r ($ arr ); $ arr = birthext ('20140901'); print_r ($ arr );

The output is as follows:

The above is a function method for php to obtain information such as constellation information and Zodiac signs based on the date or time stamp. I hope it will be helpful for your learning.

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.