you output your json by hand and then you call json_encode on an empty array() - $json
json_encode() outputs [] on you pass an empty array so your last [] comes from here $jsonstring = json_encode($json);
echo $jsonstring;
Edit: More about json_encode json_encode php manual