PHP json_decode无法将json字符串中的相同属性键转换为数组


Cannot convert the same properties key in json string to array by PHP json_decode

<?php
     $array = json_decode('{"image":"9794948495.jpg","image":"9703471814.jpg","image":"9711995133.jpg"}');
     echo json_encode($array,JSON_FORCE_OBJECT);
?>

我的代码是这样的。结果是:

{"image":"9711995133.jpg"}

你们能帮我弄到:

{"image":"9794948495.jpg","image":"9703471814.jpg","image":"9711995133.jpg"}

必须将image声明为数组:

{"image":["9794948495.jpg","9703471814.jpg","9711995133.jpg"]}

你的格式每次覆盖image键,你最终与最后解析的值:

{"image":"9794948495.jpg","image":"9703471814.jpg","image":"9711995133.jpg"}

当您将var_dump数组时,您将拥有:

array(1) { ["image"]=> array(3) { [0]=> string(14) "9794948495.jpg" [1]=> string(14) "9703471814.jpg" [2]=> string(14) "9711995133.jpg" } }

即原:$images = array('image'=>array("9794948495.jpg","9703471814.jpg","9711995133.jpg"));