时间:2021-07-01 10:21:17 帮助过:6人阅读
有人吗??
这个点
$s =<<< TXT{"arr": [ { "a": "XXX" }, { "a": "YYY" }]}TXT;$t = json_decode($s, 1);array_walk($t['arr'], function(&$v) {$v = current($v);});print_r($t);echo json_encode($t);
Array( [arr] => Array ( [0] => XXX [1] => YYY )){"arr":["XXX","YYY"]}
或
$t['arr'] = array_map('current', $t['arr']);echo json_encode($t);
$v){ array_push($tmp, $v['a']);}$result = array('arr'=>array($tmp));header('content-type:application/json');echo json_encode($result, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);?>