From 2848daa67a4c10315263336191883ffadaf72bed Mon Sep 17 00:00:00 2001 From: yf <291323003@qq.com> Date: Sat, 16 Mar 2019 00:40:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81*=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SplArray.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/SplArray.php b/src/SplArray.php index a6d0562..4b949af 100644 --- a/src/SplArray.php +++ b/src/SplArray.php @@ -66,30 +66,30 @@ function get($path) $paths = explode(".", $path); $data = $this->getArrayCopy(); while ($key = array_shift($paths)){ - if($key == '*'){ - $temp = []; - if(is_array($data)){ - if(!empty($paths)){ - $path = implode("/",$paths); - }else{ - $path = null; - } - foreach ($data as $key => $datum){ - if(is_array($datum)){ - $ctemp = (new SplArray($datum))->get($path); - if($ctemp !== null){ - $temp[][$path] = $ctemp; - } - }else if($datum !== null){ - $temp[$key] = $datum; + if(isset($data[$key])){ + $data = $data[$key]; + }else{ + if($key == '*'){ + $temp = []; + if(is_array($data)){ + if(!empty($paths)){ + $path = implode("/",$paths); + }else{ + $path = null; } + foreach ($data as $key => $datum){ + if(is_array($datum)){ + $ctemp = (new SplArray($datum))->get($path); + if($ctemp !== null){ + $temp[][$path] = $ctemp; + } + }else if($datum !== null){ + $temp[$key] = $datum; + } + } } - } - return $temp; - }else{ - if(isset($data[$key])){ - $data = $data[$key]; + return $temp; }else{ return null; }