农历算法PHP源码

functionlunarcalendar($month,$year){global$lnlunarcalendar;//农历每月的天数。每个元素为一年。每个元素中的数据为:[0]是闰月在哪个月,0为无闰月;[1]到[13]是每年12或13个月的每月天数;[14]是当年的天干次序,[15]是当年的地支次序$everymonth=array(0=>array(8,0,0,0,0,0,0,0,0,0,0,0,29,30,7,1),1=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,8,2),2=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,9,3),3=>array(5,29,30,29,30,29,29,30,29,29,30,30,29,30,10,4),4=>array(0,30,30,29,30,29,29,30,29,29,30,30,29,0,1,5),5=>array(0,30,30,29,30,30,29,29,30,29,30,29,30,0,...

PHP计算两个日期相隔多少年,多少月,多少天

/**function:计算两个日期相隔多少年,多少月,多少天*paramstring$date1[格式如:2011-11-5]*paramstring$date2[格式如:2012-12-01]*returnarrayarray('年','月','日');*/functiondiffDate($date1,$date2){if(strtotime($date1)>strtotime($date2)){$tmp=$date2;$date2=$date1;$date1=$tmp;}list($Y1,$m1,$d1)=explode('-',$date1);list($Y2,$m2,$d2)=explode('-',$date2);$Y=$Y2-$Y1;$m=$m2-$m1;$d=$d2-$d1;if($d<0){$d+=(int)date('t',strtotime("-1month$date2"));$m--;}if($m<0){$m+=12;$Y--;}returnarray('year'=>$Y,'month'=>$m,'day'=>$d);}如...

thinkphp Excel上传、读取、数据导出

首先安装composer在thinkphp根目录执行安装命令 composerrequirephpoffice/phpexcel安装phpExcel类Excel上传publicfunctionexportExcel(){$file=request()->file('excel');if(!file_exists($_SERVER['DOCUMENT_ROOT'].'/uploads/excel/')){mkdir($_SERVER['DOCUMENT_ROOT'].'/uploads/excel/',0777,true);}$info=$file->move($_SERVER['DOCUMENT_ROOT'].'/uploads/excel/');if($info->getExtension()!='xlsm'&&$info->getExtension()!='xls'){return'格式不正确';}$saveUrl=str_replace('\','/',$_SERVER['DOCUMENT_ROOT'].'/uploads/exc...

php获取今天、昨天、明天的日期

echo"今天:".date("Y-m-d")."<br>";echo"昨天:".date("Y-m-d",strtotime("-1day")),"<br>";echo"明天:".date("Y-m-d",strtotime("+1day"))."<br>";echo"一周后:".date("Y-m-d",strtotime("+1week"))."<br>";echo"1周零2天8小时2秒后:".date("Y-m-dG:H:s",strtotime("+1week2days8hours2seconds"))."<br>";echo"下个星期四:".date("Y-m-d",strtotime("nextThursday"))."<br>";echo"上个周一:".date("Y-m-d",strtotime("lastMonday"))."<br>";echo"一个月前:".date("Y-m-d",strtotime("lastmonth"))."<br>";echo"一个月后:"....

php 随机生成姓名代码

php随机生成姓名代码<?php/***@paraminteger$sex1男2女0不限*@paramstring$x固定姓*@paramboolen$fx是否加入复姓true是false否*@returnarray[‘x‘=>‘姓‘,‘m‘=>‘名‘,‘xm‘=>‘姓名‘]*/functiongenerate_name($sex=0,$x=null,$fx=true){//单姓$xing_d=[‘赵‘,‘钱‘,‘孙‘,‘李‘,‘周‘,‘吴‘,‘郑‘,‘王‘,‘冯‘,‘陈‘,‘褚‘,‘卫‘,‘蒋‘,‘沈‘,‘韩‘,‘杨‘,‘朱‘,‘秦‘,‘尤‘,‘许‘,‘何‘,‘吕‘,‘施‘,‘张‘,‘孔‘,‘曹‘,‘严‘,‘华‘,‘金‘,‘魏‘,‘陶‘,‘姜‘,‘戚‘,‘谢‘,‘邹‘,‘喻‘,‘柏‘,‘水‘,‘窦‘,‘章‘,‘云‘,‘苏‘,‘潘‘,‘葛‘,‘奚‘,‘范‘,‘彭‘,‘郎‘,‘鲁‘,‘韦‘,‘昌‘,‘马‘,‘苗‘,‘凤‘,‘花‘,‘方‘,‘任‘,‘袁‘,‘柳‘,‘鲍‘,‘史‘,‘唐‘,‘费‘,‘薛‘,‘雷‘,‘贺‘,‘倪‘,‘汤‘,‘滕‘,‘殷‘,‘罗‘,‘毕‘,...

PHP去除字符串的前后空格

1、使用trim()函数去掉空格trim($val)2、使用正则表达式去掉空格preg_replace('','',$val) ...

php报500错误时显示所有错误

在php文件的开头输入ini_set("display_errors","On");error_reporting(E_ALL|E_STRICT); ...
开发笔记 开发笔记·2021-07-03

php判断字符串中是否包含另一个字符串

<?phpif(strpos('www.51dev.com','www')!==false){echo'www.51dev.com包含该www';}else{echo'www.51dev.com不包含该字符串www';}?> ...

php冒泡排序算法

functionff($arr){for($i=0;$i<count($arr);$i++){$isSort=false;for($j=0;$j<count($arr)-$i-1;$j++){if($arr[$j]<$arr[$j+1]){$isSort=true;$temp=$arr[$j];$arr[$j]=$arr[$j+1];$arr[$j+1]=$temp;}}if($isSort){break;}}return$arr;}$arr=array(3,1,2);var_dump(ff($arr));?> ...
开发笔记 开发笔记·2021-04-26

php时间戳格式化方法

//时间戳格式化$time = time(); 时间戳格式date("Y-m-d H:i:s",strtotime( $time  )); //返回2021-04-24 46:46:50 这样的格式...

php判断多维数组是否存在某个值

functionfind_in_array($value,$array){foreach($arrayas$item){if(!is_array($item)){if($item==$value){returntrue;}else{continue;}}if(in_array($value,$item)){returntrue;}elseif(deep_in_array($value,$item)){returntrue;}}returnfalse;} ...

php通过计算对象名称动态获取对象属性值

$attr='field'.$key;$myobject->$attr;或者$myobject->{'field_'.$key}; ...

php验证文件mine类型的函数mime_content_type

php的mime_content_type函数可以返回文件的类型,用法如下:<?phpechomime_content_type('php.gif')."";echomime_content_type('test.php');?>输出:image/giftext/plain ...

php缩短网址代码

<?phpprint_r(shorturl('http://www.51dev.com'));functionshorturl($input){$base32=array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5');$hex=md5($input);$hexLen=strlen($hex);$subHexLen=$hexLen/8;$output=array();for($i=0;$i<4;$i++){//把加密字符按照8位一组16进制与0x3FFFFFFF(30位1)进行位与运算$subHex=substr($hex,$i*8,8);$int=hexdec($subHex)&0x3fffffff;//$int=0x3fffffff&1*('0x'.$subHex);$out='';for($j=0;$j<6;$j++){//把得到的值与0x...
开发笔记 开发笔记·2021-03-07

php去掉标签

functionremoveLabel($input){$ret=trim(strip_tags($input));$ret=preg_replace("/&quot;/is","",$ret);$ret=preg_replace("/&nbsp;/is","",$ret);$ret=htmlspecialchars($ret);return$ret;} ...
星空 星空·2021-03-01
首页上一页...56789...下一页尾页