php根据日期判断星座的函数分享
function yige_constellation($month, $day) {
// 检查参数有效性
if ($month < 1 || $month > 12 || $day < 1 || $day > 31) return false;
// 星座名称以及开始日期
$constellations = array(
array( "20" => "宝瓶座"),
array( "19" => "双鱼座"),
array( "21" => "白羊座"),
array( "20" => "金牛座"),
array( "21" => "双子座"),
array( "22" => "巨蟹座"),
array( "23" => "狮子座"),
array( "23" => "处女座"),
array( "23" => "天秤座"),
array( "24" => "天蝎座"),
array( "22" => "射手座"),
array( "22" => "摩羯座")
);
list($constellation_start, $constellation_name) = each($constellations[(int)$month-1]);
if ($day < $constellation_start) list($constellation_start, $constellation_name) = each($constellations[($month -2 < 0) ? $month = 11: $month -= 2]);
return $constellation_name;
}
调用示例:
echo yige_constellation(4, 20);
相关推荐
-
php计算十二星座的函数代码
核心代码: 复制代码 代码如下: <?php /* * 计算星座的函数 string get_zodiac_sign(string month, string day) * 输入:月份,日期 * 输出:星座名称或者错误信息 */ function get_zodiac_sign($month, $day) { // 检查参数有效性 if ($month < 1 || $month > 12 || $day < 1 || $day > 31) return (false); /
-
PHP用身份证号获取星座和生肖的方法
复制代码 代码如下: <?php // PHP根据身份证号,自动获取对应的星座函数 function get_xingzuo($cid) { // 根据身份证号,自动返回对应的星座 if (!isIdCard($cid)) return ''; $bir = substr($cid,10,4); $month = (int)substr($bir,0,2); $day = (int)substr($bir,2); $strValue = ''; if (($month == 1 &
-
php根据日期或时间戳获取星座信息和生肖等信息
分享一个利用php根据日期或时间戳获取相应的干支纪年,生肖和星座信息的函数方法,具体函数代码以及使用方法如下: /** 判断干支.生肖和星座 */ 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}
-
php根据日期显示所在星座的方法
本文实例讲述了php根据日期显示所在星座的方法.分享给大家供大家参考.具体实现方法如下: <?php function zodiac($DOB){ $DOB = date("m-d", strtotime($DOB)); list($month,$day) = explode("-",$DOB); if(($month == 3 || $month == 4) && ($day > 22 || $day < 21)){ $zodia
-
php根据日期判断星座的函数分享
复制代码 代码如下: function yige_constellation($month, $day) { // 检查参数有效性 if ($month < 1 || $month > 12 || $day < 1 || $day > 31) return false; // 星座名称以及开始日期 $constellations = array( array( "20" => "宝瓶座"), array( "19&quo
-
php计算2个日期的差值函数分享
非常简单实用的函数分享给大家, 奉上代码: 复制代码 代码如下: /** * 日期-计算2个日期的差值 * @return int */ public function get_difference($date, $new_date) { $date = strtotime($date); $new_date = strtotime($new_date); return abs(ceil(($date
-
js根据日期判断星座的示例代码
复制代码 代码如下: function xingzuo() { var start = 1901, date=document.getElementById("txtDay").value, month=document.getElementById("txtMonth").value;;with (document.getElementById("txtXZ")){ if (month == 1 && date >=20
-
asp是的日期转换为星座的函数
复制代码 代码如下: function astro(birth) astro="" if birth="" or not isdate(birth) Then exit function birthmonth=month(birth) : if birthmonth<10 then birthmonth="0" & birthmonth birthday=day(birth) : if birthday<10 then bir
-
sql通过日期判断年龄函数的示例代码
定义函数: CREATE FUNCTION [dbo].[GetAge] ( @BirthDay nvarchar(20) --生日 ) RETURNS varchar(20) AS BEGIN if(@BirthDay is NUlL or @BirthDay='') return ''; -- Declare the return variable here DECLARE @age varchar(20) DECLARE @years int DECLARE @months int DEC
-
JS根据生日月份和日期计算星座的简单实现方法
本文实例讲述了JS根据生日月份和日期计算星座的简单实现方法.分享给大家供大家参考,具体如下: 看到了别人写的一个计算星座的js,冗长的有点儿看不过去,就自己写个了. 我想,这个函数应该足够精简了:) 什么 if 啊 switch 啊 for 啊 通通滚蛋了-- 传入参数:month [int] 1-12; day [int] 1-31. // 根据生日的月份和日期,计算星座. function getAstro(month,day){ var s="魔羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎
-
JavaScript常用的工具函数分享
目录 格式化时间戳 时间格式化 几分钟前 几小时前 url参数转为对象 对象序列化[对象转url参数] 本地存储 cookie操作 数字格式化单位 数字千位过滤 过滤成版本号 首字母大写 class 操作 文本复制功能 判断是否是一个数组 判断是否是一个空数组 克隆一个数组 数组去重 是否为PC端 判断是否为微信 设备判断:android.ios.web 常见正则校验 去除字符串空格 过滤html代码 生成随机数范围 判断图片加载完成 光标所在位置插入字符 图片地址转base64 base64图
-
javascript 简单高效判断数据类型 系列函数 By shawl.qiu
说明: 前段时间把 ASP VBScript 掌握得差不多的时候, 就转而学习 Javascript/Jscript, 主要是学 Jscript 啦. 不过这两者基本上没什么区别, 唯一不同的是 Jscript 没有客户端的概念. 在刚开始时, 发现 VBS 的一些实用函数 Js 好多都没有, formatNumber 呀 isArray 呀 isDate 呀 等等. 还有日期对象也是很奇怪, 不能直接加加减减, 要set***... 不过对 Javascript/Jscript 掌握到一
-
js中判断变量类型函数typeof的用法总结
1.作用: typeof 运算符返回一个用来表示表达式的数据类型的字符串. 可能的字符串有:"number"."string"."boolean"."object"."function" 和 "undefined". 2.常用返回值说明 表达式 返回值 typeof undefined 'undefined' typeof null 'object' typeof true 'boole
-
python实现根据月份和日期得到星座的方法
本文实例讲述了python实现根据月份和日期得到星座的方法.分享给大家供大家参考.具体实现方法如下: #计算星座 def Zodiac(month, day): n = (u'摩羯座',u'水瓶座',u'双鱼座',u'白羊座',u'金牛座',u'双子座',u'巨蟹座',u'狮子座',u'处女座',u'天秤座',u'天蝎座',u'射手座') d = ((1,20),(2,19),(3,21),(4,21),(5,21),(6,22),(7,23),(8,23),(9,23),(10,23),(11
随机推荐
- JS使用tofixed与round处理数据四舍五入的区别
- AngularJS基础知识笔记之过滤器
- Angular 2父子组件数据传递之@ViewChild获取子组件详解
- iexplore.exe真正解决问题的方法 原创
- Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置的详细方法
- 用批处理设置IP安全策略的代码
- Java微信公众平台开发(2) 微信服务器post消息体的接收
- SpringMVC和Swagger整合方法
- ORACLE错误一览表 方便查询
- 设置oralce自动内存管理执行步骤
- php基本函数汇总
- C++派生访问说明符小记(推荐)
- Mysql使用简单教程(三)
- 纯CSS生成抗锯齿圆角的代码
- jQuery中调用WebService方法小结
- Javascript实现的鼠标经过时播放声音
- 关于使用 jBox 对话框的提交不能弹出问题解决方法
- JQuery球队选择实例
- QQ游戏启动加速程序使用说明图文教程
- C#窗体显示留言时间的方法