commit | author | age
|
90c639
|
1 |
<?php |
Z |
2 |
/** |
|
3 |
* Created by PhpStorm |
|
4 |
* User: 风哀伤 |
|
5 |
* Date: 2020/9/3 |
|
6 |
* Time: 3:48 下午 |
|
7 |
* @copyright: ©2020 浙江禾匠信息科技 |
|
8 |
* @link: http://www.zjhejiang.com |
|
9 |
*/ |
|
10 |
|
|
11 |
namespace app\helpers; |
|
12 |
|
|
13 |
class ArrayHelper extends \yii\helpers\ArrayHelper |
|
14 |
{ |
|
15 |
/** |
|
16 |
* @param $array |
|
17 |
* @param $keys |
|
18 |
* @param null $default |
|
19 |
* @return array|mixed|null |
|
20 |
* 批量删除键值 |
|
21 |
*/ |
|
22 |
public static function removeList(&$array, $keys, $default = null) |
|
23 |
{ |
|
24 |
if (!is_array($keys)) { |
|
25 |
return $default; |
|
26 |
} |
|
27 |
$value = []; |
|
28 |
while (count($keys) > 1) { |
|
29 |
$key = array_shift($keys); |
|
30 |
$value[] = self::remove($array, $key, $default); |
|
31 |
} |
|
32 |
return $value; |
|
33 |
} |
|
34 |
|
|
35 |
public static function filter($array, $filters) |
|
36 |
{ |
|
37 |
if (empty($filters)) { |
|
38 |
return $array; |
|
39 |
} else { |
|
40 |
return parent::filter($array, $filters); |
|
41 |
} |
|
42 |
} |
|
43 |
} |