From PHP code I want to create an json array:
[ {"region":"valore","price":"valore2"}, {"region":"valore","price":"valore2"}, {"region":"valore","price":"valore2"} ]
How can I do this?
Easy peasy lemon squeezy: http://www.php.net/manual/en/function.json-encode.php
<?php $arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5); echo json_encode($arr); ?>
There's a post by andyrusterholz at g-m-a-i-l dot c-o-m on the aforementioned page that can also handle complex nested arrays (if that's your thing).
andyrusterholz at g-m-a-i-l dot c-o-m
2.1m questions
2.1m answers
60 comments
57.0k users