I have this simple array with 2 elements which is being converted into json format:
echo '['.json_encode(array("name" => "FRENCH POLYNESIA", "name" => "POLAND")).']';
The result is: [{"name":"POLAND"}]
In my case I need this result: [{"name": "FRENCH POLYNESIA"},{"name": "POLAND"}] How I can do this ?
json_decodeyou will not be able to initialize array with key duplicated. so change/fix array initialization up to your needs