共同函数 Helper
dump(val);
如果运行环境是开发环境 [ ENVIRONMENT
= development
]
调试数据后结束进程。
dump_query();
如果运行环境是开发环境 [ ENVIRONMENT
= development
]
显示最后运行的SQL语句,这个不会结束进程。
qiniu_img(url, width, height, option);
0. 不使用 $option
$img_url = 'http://ohutkvbbx.bkt.clouddn.com/img.png';
echo qiniu_img($img_url, 260, 150);
// http://ohutkvbbx.bkt.clouddn.com/img.png?imageMogr2/thumbnail/!260x150r/gravity/Center/crop/260x150/interlace/1
1. $option使用String方式 :现在只支持 crop,fit。 默认:fit
echo qiniu_img($img_url, 260, 150, 'crop');
// http://ohutkvbbx.bkt.clouddn.com/img.png?imageMogr2/gravity/Center/crop/260x150
2. $option使用Array方式
$crop = array(
'gravity'=>'SouthEast' //省略就默认Center
,'size'=>'200x300' //可省略,自动获取$width,$height
,'position'=>'a50a100' //偏移
);
$option = array('crop'=>$crop);
echo qiniu_img($img_url, 260, 150, $option);
// http://ohutkvbbx.bkt.clouddn.com/img.png?imageMogr2/gravity/SouthEast/crop/!200x300a50a100
3. $option使用自定义方式 !注意:宽高60,50会丢失
详细的看七牛文档
$option = array('etc'=>'/rotate/45');
echo qiniu_img($img_url, 60, 50, $option);
// http://ohutkvbbx.bkt.clouddn.com/img.png?imageMogr2/rotate/45
备注:什么是渐进显示?
七牛文档里有interlace/1
这个选项,老看看到底是有毛用。
普通显示
渐进显示
fillter_data(date, fillter)
过滤没必要的数组
/**
* 过滤没必要的数组
* @param [array] $date [数据源]
* @param [array] $fillter [要选取的数据,key数组]
* @return [array] [过滤后的数据,没有则返回空的数组]
*/
function fillter_data($date, $fillter)
{
$return = array();
foreach ($fillter as $v) {
if (isset($date[$v])) {
$return[$v] = $date[$v];
}
}
return $return;
}
使用方法
$data = array(
'a'=>'1'
,'b'=>'2'
,'c'=>'3'
,'d'=>'4'
,'e'=>'5'
);
$output = fillter_data($data, array('a','c','e'));
print_r($output);
// Array ( [a] => 1 [c] => 3 [e] => 5 )