function data2lua($data) { $data = json_encode($data, JSON_UNESCAPED_UNICODE); $lists = mbStrSplit($data); $length = count($lists); $frontPos = -1; $i = 0; for ($i = 0; $i < count($lists); $i++) { $one = $lists[$i]; if ($one == '[') { $lists[$i] = '{'; } else if ($one == ']') { $lists[$i] = '}'; } else if ($one == '"' and $i < ($length - 1) and $lists[$i + 1] != ':') { $frontPos = $i; } else if ($one == ':' and $i >= 2 and $lists[$i - 1] == '"' and $lists[$i - 2] != ':' and $frontPos > -1) { $lists[$frontPos] = '["'; $lists[$i - 1] = '"]'; $lists[$i] = "="; $frontPos = -1; } } $lists = join($lists, ""); return $lists; }
JSON 转lua table php版
Stella981
2021-10-11
1432 0 0
点赞
收藏
评论区
加载中...