json_encode시 null을 없애기 위한 코드 추가

This commit is contained in:
2018-02-09 01:32:44 +09:00
parent 47016d7224
commit 8b20985668
+18
View File
@@ -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/