1function data2lua($data) 2 { 3 $data = json_encode($data, JSON_UNESCAPED_UNICODE); 4 $lists = mbStrSplit($data); 5 $length = count($lists); 6 $frontPos = -1; 7 $i = 0; 8 for ($i = 0; $i < count($lists); $i++) { 9 $one = $lists[$i]; 10 if ($one == '[') { 11 $lists[$i] = '{'; 12 } else if ($one == ']') { 13 $lists[$i] = '}'; 14 } else if ($one == '"' and $i < ($length - 1) and $lists[$i + 1] != ':') { 15 $frontPos = $i; 16 } else if ($one == ':' and $i >= 2 and $lists[$i - 1] == '"' and $lists[$i - 2] != ':' and $frontPos > -1) { 17 $lists[$frontPos] = '["'; 18 $lists[$i - 1] = '"]'; 19 $lists[$i] = "="; 20 $frontPos = -1; 21 } 22 } 23 $lists = join($lists, ""); 24 return $lists; 25 }
JSON 转lua table php版
Stella981
2021-10-11
1435 0 0
点赞
收藏
评论区
加载中...