php數組相關操作函數
阿新 • • 發佈:2018-02-27
str 一個數 ret _array pos UC enc highlight 空數組
判斷是否是一個數組
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) {}
更新中.....
php數組相關操作函數