生成json映射表代码
<?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);
?>