0%

生成json映射表

生成json映射表代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
$dic = [
'qd' => [...],
'mp' => [... 100],
'jl' => [...],
'sb' => [..., 50, 60, 70, 85, 100],
'ly' => [..., 50, 60, 70, 85, 100],
'dy' => [...0, 50, 60, 70, 85, 100],
'sl' => [...55, 60, 65, 70, 85, 100],
'xl' => [... 50, 55, 65, 75, 85, 100],
'vl' => [...50, 60, 70, 80, 90, 100],
'rh' => [... 100]
];
function getJson($dic) {
$res = [];
foreach($dic as $k => $v){
$res[$k] = [];
foreach($v as $key => $val) {
$res[$k]['mapV'][$key] = [
'label' => (string)$key,
'value' => (string)$val
];
}
}
var_dump(json_encode($res));
}
getJSON($dic);
?>