语法:filter_var(variable, filter, options)
参数
描述
variable
必需。规定要过滤的变量。
filter
可选。规定要使用的过滤器的 ID。
options
规定包含标志/选项的数组。检查每个过滤器可能的标志和选项...
				 
		
				
                 	
						
				
						
                	[codesyntax lang="php"]
/**
 * 校验日期格式是否合法
 * @param string $date
 * @param array $formats
 * @return bool
 */
function isDateValid($date, $formats = array('Y-m-d', 'Y/m/d', 'Y/n/j')) {
    $unixTime ...
				 
		
				
                 	
						
				
						
                	定义和用法
array_reduce() 函数向用户自定义函数发送数组中的值,并返回一个字符串。
注释:如果数组是空的且未传递 initial 参数,该函数返回 NULL。
说明
array_reduce() 函数用回调函数迭代地将数组简化为单一的值。
...
				 
		
				
                 	
						
				
						
                	说明 
array array_unique ( array $array [, int $sort_flags = SORT_STRING ] )
array_unique() 接受 array 作为输入并返回没有重复值的新数组。
注意键名保留不变。array_unique() 先将值作为字符串排序,然后对每个值只保...
				 
		
				
                 	
						
				
						
                	[codesyntax lang="php"]
$file=$_FILES['file'];
$fileName=$file['tmp_name'];
if (!$files = fopen($fileName, 'r')) {
    echo "文件读取失败";
    exit;
}
$data = [];
fgetcsv($files); // skip table head
while ...
				 
		
				
                 	
						
				
						
                	1. 开机启动nginx:
在 /Library/LaunchDaemons/ 目录新建 org.macports.nginx.plist 文件:
[codesyntax lang="xml"]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST ...
				 
		
				
                 	
						
				
						
                	[codesyntax lang="php"]
$input1 = [
    [
        'id' => 4,
        'name' => '44'
    ],
    [
        'id' => 2,
        'name' => '22'
    ],
    [
        'id' => 3,
        'name' =>...
				 
		
				
                 	
						
				
						
                	array_filter — 用回调函数过滤数组中的单元
[codesyntax lang="php"]
$input = [
    [
        'id' => 1,
        'name' => '11'
    ],
    [
        'id' => 2,
        'name' => '22'
    ],
    [...
				 
		
				
                 	
						
				
						
                	[codesyntax lang="php"]
$a1=array("Pluto","Fido","Missy");
array_multisort($a1,SORT_ASC);
print_r($a1);
[/codesyntax]
 
打印结果:
[codesyntax lang="php"]
Array
(
    [0] => Fido
    [1] =>...
				 
		
				
                 	
						
				
						
                	[codesyntax lang="php"]
//产生一个10000的一个数组。
$max = 10000;
$test_arr = range(0, $max);
$temp = 0;
//我们分别用三种方法测试求这些数加上1的值的时间。
// for 的方法
$t1 = microtime(true);
for ($i = 0; $i...
				 
		
				
                 	
						
				
						
                	[codesyntax lang="php"]
header('content-type:text/html;charset=utf-8');
//生命一个计算脚本运行时间的类
class Timer
{
    private $startTime = 0; //保存脚本开始执行时的时间(以微秒的形式保存)
    private $stop...
				 
		
				
                 	
						
				
						
                	array_udiff — 用回调函数比较数据来计算数组的差集
[codesyntax lang="php"]
array array_udiff ( array $array1 , array $array2 [, array $... ], callable $value_compare_func )
[/codesyntax]
使用回调函数比较数据,计算数...
				 
		
				
                 	
						
				
						
                	[codesyntax lang="php"]
<?php
class Time
{
    /**
     * 返回今日开始和结束的时间戳
     *
     * @return array
     */
    public static function today()
    {
        return [
            mktime(0, 0...
				 
		
				
                 	
						
				
						
                	
将请求存入redis为了模拟多个用户的请求,使用一个for循环替代
[codesyntax lang="php"]
//redis数据入队操作
$redis = new Redis();
$redis->connect('127.0.0.1',6379);
for($i=0;$i<50;$i++){
    try{
     ...