摘要: 两分法查找的前提:顺序方式存储,而且必须是排好序直接上代码:function search($array, $target, $low = 0, $high = 0){ $len = count($array); $low = max($low, 0); $high = $high... 阅读全文
posted @ 2014-04-25 12:06 再見理想 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 1 # Filename:mysql_class.py 2 # Author:Rain.Zen; Date: 2014-04-15 3 4 import MySQLdb 5 6 class MyDb: 7 8 '''初始化[类似于构造函数]''' 9 def... 阅读全文
posted @ 2014-04-15 19:31 再見理想 阅读(599) 评论(0) 推荐(0) 编辑
摘要: 直接上代码:# while.pynumber = 23isRun = Truewhile isRun: intt = int(raw_input('请输入一个整数 : ')) if intt == number: print '恭喜您, 您猜对了.' isRun = False elif intt < number: print '哎呀,您的数字小了.' else: print '哎呀,您的数字大了.' else: print '呵呵,循环完毕.' 阅读全文
posted @ 2014-04-11 19:41 再見理想 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 直接上代码:$str = '192.168.2.100';echo 'IP:',$str,'';$int = ip_long($str);echo $int,'';echo long_ip($int);function ip_long($ip) { $ary = explode('.', $ip); return count($ary) == 4 ? $long = $ary[0] + ($ary[1] 255 ? ($int & 255).'.'.(($int >> 8) &a 阅读全文
posted @ 2014-04-10 16:36 再見理想 阅读(272) 评论(0) 推荐(0) 编辑
摘要: toString():把数组转换成一个字符串toLocaleString():把数组转换成一个字符串join():把数组转换成一个用符号连接的字符串shift():将数组头部的一个元素移出unshift():在数组的头部插入一个元素pop():从数组尾部删除一个元素push():把一个元素添加到数组的尾部concat():给数组添加元素slice():返回数组的部分reverse():将数组反向排序sort():对数组进行排序操作splice():插入、删除或者替换一个数组元素JS的数组创建(多维) JS的数组创建(多维) 阅读全文
posted @ 2014-03-28 11:25 再見理想 阅读(6380) 评论(0) 推荐(0) 编辑
摘要: 页面HTML代码 JS输出日历 下面是calendar.js的代码$(document).ready(function(){ function createCalendar(year, month){ var _Date = new Date(), _thenYear = _Date.getFullYear(), _thenMonth = _Date.getMonth() + 1, _thenDay = _Date.getDate(); var aryMonth = ['一', '二', '三', '四', '五' 阅读全文
posted @ 2014-03-25 18:58 再見理想 阅读(1382) 评论(0) 推荐(0) 编辑
摘要: 以下代码只是简单实现日历的效果和逻辑思路,没有使用类封装,权当抛砖引玉,有兴趣的朋友可以封装起来,方便调用。';foreach($aryWeek as $v){ $weekTrHtml.= '周'.$v.'';}$weekTrHtml.= '';unset($v);// 以下为计算当月的天数以及前后月份作为空位补齐日历表格$allDay = calenderNum('t', $year, $month, $thenDay); // 指定月份的天数$monthFirstDay2weekVal = calenderNum(&# 阅读全文
posted @ 2014-03-25 11:56 再見理想 阅读(970) 评论(0) 推荐(0) 编辑
摘要: 运用了date()和strtotime()函数,直接上代码echo date('Y-m-d' , strtotime('-1 day')).PHP_EOL;echo date('Y-m-d' , strtotime('-1 week')).PHP_EOL;echo date('Y-m-d' , strtotime('-1 month')).PHP_EOL;echo date('Y-m-d' , strtotime('-1 year')).PHP_EOL;/** 输出2 阅读全文
posted @ 2014-03-25 11:05 再見理想 阅读(981) 评论(0) 推荐(0) 编辑
摘要: mktime() 函数对于日期运算和验证非常有用。它可以自动校正越界的输入:// 语法:mktime(hour,minute,second,month,day,year)echo(date('Y-m-d', mktime(0,0,0, 12, 36, 2001)));echo(date('Y-m-d', mktime(0,0,0, 14, 1, 2001)));echo(date('Y-m-d', mktime(0,0,0, 1, 1, 2001)));echo(date('Y-m-d', mktime(0,0,0, 1, 1, 阅读全文
posted @ 2014-03-25 10:54 再見理想 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 例:echo date('Y-m-d H:i:s', time()); 输出时间:2008-10-12 02:32:17 但实际时间是:2008-10-12 10:32:17时间误差8个小时PHP手册的例子的第一行多了一个时区设置:date_default_timezone_set('UTC');原来php5.1.开始,php.ini里加入了date.timezone这个选项,默认情况下是关闭的,也就是显示的时间(无论用什么php命令)都是格林威治标准时间,和北京时间正好差8个小时。如何设置可以得到正确的PHP时间,两种方式?1、修改php.ini。打开php. 阅读全文
posted @ 2014-03-25 10:35 再見理想 阅读(858) 评论(0) 推荐(0) 编辑