dictionary(php에선 associative array) 여부 확인하는 코드 추가

메시지 전송 코드를 message에 json을 이용하도록 변경. 외교 서신 등을 위한 $option을 추가
This commit is contained in:
2018-02-09 02:02:38 +09:00
parent 8b20985668
commit 1eb3944b8a
2 changed files with 35 additions and 14 deletions
+27 -2
View File
@@ -249,7 +249,32 @@ function dictToArray($dict, $keys){
return $result;
}
function eraseNullKey(&$dict, $depth=512){
function isDict(&$array){
if(!is_array($array)){
//배열이 아니면 dictionary 조차 아님.
return false;
}
$idx = 0;
$jmp = 0;
foreach ($arr as $key=>&$value) {
if(is_string($key)){
return true;
}
$jmp = $key - $idx - 1;
$idx = $key;
}
if ($jmp * 5 >= count($array)){
//빈칸이 많으면 dictionary인걸로.
return true;
}
else{
return false;
}
}
function eraseNullValue(&$dict, $depth=512){
//TODO:Test 추가
if($depth <= 0){
return $dict;
@@ -259,7 +284,7 @@ function eraseNullKey(&$dict, $depth=512){
if($value === null){
unset($dict[$key]);
}
else if(is_array($value)){
else if(isDict($value)){
$dict[$key] = eraseNullKey($value, $depth - 1);
}
}