From 8b209856682c3ad9de6aa0675306805c2cbdf635 Mon Sep 17 00:00:00 2001 From: hide_d Date: Fri, 9 Feb 2018 01:31:48 +0900 Subject: [PATCH] =?UTF-8?q?json=5Fencode=EC=8B=9C=20null=EC=9D=84=20?= =?UTF-8?q?=EC=97=86=EC=95=A0=EA=B8=B0=20=EC=9C=84=ED=95=9C=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- twe/lib.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/twe/lib.php b/twe/lib.php index 19c96ae0..08d47efe 100644 --- a/twe/lib.php +++ b/twe/lib.php @@ -249,6 +249,24 @@ function dictToArray($dict, $keys){ return $result; } +function eraseNullKey(&$dict, $depth=512){ + //TODO:Test 추가 + if($depth <= 0){ + return $dict; + } + + foreach ($arr as $key=>$value) { + if($value === null){ + unset($dict[$key]); + } + else if(is_array($value)){ + $dict[$key] = eraseNullKey($value, $depth - 1); + } + } + + return $dict; +} + function parseJsonPost(){ // http://thisinterestsme.com/receiving-json-post-data-via-php/ // http://thisinterestsme.com/php-json-error-handling/