我有以下格式的json数据
["0","0","0","0","0","0","0","2","5","4","3","0"]
我想使用php
将上述数据转换为以下格式[0,0,0,0,0,0,0,2,5,4,3,0]
我如何使用php
执行此操作由于
答案 0 :(得分:2)
您可以使用array_map将数组中的所有项类型转换为带回调intval的整数。
对于数组中的整数:
$array = array_map('intval', json_decode('["0","0","0","0","0","0","0","2","5","4","3","0"]'));
从数组中检索JSON:
echo json_encode($array);
答案 1 :(得分:0)
$string = '["0","0","0","0","0","0","0","2","5","4","3","0"]';
echo str_replace('"','', $string);
输出是:
[0,0,0,0,0,0,0,2,5,4,3,0]