判断是否是一个数组
- function _is_array($value){
- if (is_array($value)) {
- return true;
- } else {
- if(is_object($value) && is_array(json_decode(json_encode($value),true))){
- return true;
- }
- return (is_object($value) AND $value instanceof \Traversable);// 实现这个接口对象可以 foreach
- }
- }
清空数组
- function _destruct_one($object) {
- if (_is_array($object)) {
- $length = count($object);
- while ($length--) {
- array_splice($object, $length, 1);
- }
- }
- return $object;
- }
- var_dump(_destruct_one([1, 2, d, key = >k])); //array(0) {}
更新中.....
来源: http://www.bubuko.com/infodetail-2509142.html