-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDNS_Model.php
executable file
·53 lines (43 loc) · 1.24 KB
/
DNS_Model.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
class DNS_Model extends CI_Model{
protected $error = '';
public function __construct() {
parent::__construct();
}
public function get_error(){
return $this->error;
}
/**
* 从数组中获取数据
* @param type $array 数组
* @param type $key 键值
* @param type $default 默认值
* @param type $filter 过滤函数
*/
public static function _g($array = array(), $key = '', $default = '', $filter = '')
{
if (isset($array[$key])) {
$default = $array[$key];
}
if (function_exists($filter)) {
$default = $filter($default);
}
return $default;
}
/**
* 更改数组key(如在account列表中修改改为account_id作为key)
* @param array $array
* @param type $key
* @param type $filter
* @return array
*/
public static function _ary_change_key(array $array, $key, $filter = '')
{
$ret = array();
foreach ($array as $v) {
$kval = self::_g($v, $key, '', $filter);
$ret[$kval] = $v;
}
return $ret;
}
}