分类 PHP/Python/Java 下的文章

php多维数组排序方法

php二维数组排序,php多维数组排序函数/**  * 二维数组排序/多维数组排序 PHP  * @param multi_array 多维数组名称  * @param sort_key 二维数组的键名(要排序的键名)  * @param sort 排序常量 SORT_ASC || SORT_DESC  * @return multi_array 排序后的数组数据  */  function ...

继续阅读 »

获取IP地址及对应城市函数 PHP

**获取客户IP地址** ```php function get_proxy_ip(){ $arr_ip_header = array( 'HTTP_CDN_SRC_IP', 'HTTP_PROXY_CLIENT_IP', 'HTTP_WL_PROXY_CLIENT_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR', ); $client_ip = '127.0.0.1'; foreach ($arr_ip_header as $key){ if (!empty($_SERVER[$key]) && strtolower($_SERVER[$key]) != 'unknow...

继续阅读 »

PHP人民币大小写转换类(MoneyConvertor_CLS)

人民币大小写转换类 PHP:/**   * MoneyConvertor Library For PHP  * 人民币大小写转换类  * ---------------------------------------------------  * @site  https://www.fity.cn/post/534/  * @describe   对人民币进行大小写转换的类,该方法可以完美转换任何形式小写货币格式为人民币大写  */ &n...

继续阅读 »

php 毫秒

php获取毫秒数PHP microtime()返回当前 Unix 时间戳和微秒数。php本身没有提供返回毫秒数的函数,但提供了一个microtime()函数,该函数返回秒数和小数表示的毫秒数两个元素,借助此函数,可以很容易定义一个返回毫秒数的函数:function getMsec() {      list($us, $s) = explode(' ', microtime());      return (float)sprintf('%.0f', (floatval($us) +&nb...

继续阅读 »

ThinkPHP5.1 ISNULL查询空字段数据

**ThinkPHP ISNULL , ThinkPHP查询空或非空字段数据** ```sql ThinkPHP3.2 $where['age'] = array('exp',' is NULL'); $where['age'] = array('exp',' is not NULL'); ThinkPHP5.1 whereNull('level') whereNotNull('level') ``` **MySQL查找空字段或不为空的字段** MySQL查询空字段数据: ```sql select * from table where id = ''; select * from table where isnull(age); ``` **...

继续阅读 »

php获取昨天/今天/明天/上周/本月/过去N月起止时间戳

PHP获取昨天、今天、明天、上周、本月、过去几/N个月、过去半年、一年后等起始时间戳和结束时间戳的方法首先了解两个PHP函数:strtotime()函数:将任何英文文本的日期时间描述解析为 Unix 时间戳strtotime(time,now)mktime() 函数:返回一个日期的 Unix 时间戳mktime(hour,minute,second,month,day,year,is_dst)php获取昨天 今天 明天 上周 本月 一年后 十年后的开始时间戳和结束时间戳://php获取今天日期  date("Y-m-d");    //php获取昨天日期  date("Y-m-d",strtotime("-1 day...

继续阅读 »

PHP获取根域名/域名主体部分

PHP截取根域名 PHP获取域名主体部分$httpRefer = parse_url('http://fity.com.cn/new/');  $host = $httpRefer['host'];  $httpRefer  = $this->GetUrlToDomain($host);  $hostTem = explode('.',$httpRefer); //分割字符串  $host = $hostTem[0];  echo $host; //输出结果:fi...

继续阅读 »

thinkphp去重统计数据sql

##### DISTINCT 方法用于返回唯一不同的值 官方文档给出的示例: ```php $Model->distinct(true)->field('userName')->select(); 解析的SQL:SELECT DISTINCT `userName` FROM `table` ``` 去重统计: ```php $totalRows = $this->where($where)->count('DISTINCT mobilePhone') 解析的SQL:SELECT COUNT(DISTINCT mobilePhone) AS tp_count FROM `table` WHERE `check` = 1 ```

继续阅读 »

urlencode与urldecode使用

urlencode与urldecode使用例如,URL地址:https://www.fity.cn?test.php&num=8#88一般这种情况我们会对url进行编码后传送,以便能完整的获取到数据:http://www.fity.cn/test.php?num=<?php echo urlencode('8#88');?>  在取num数据时使用:$num = urldecode($_GET['num']);  echo $num;  

继续阅读 »