update(array("loc1"=>$locations[0]),array('$set'=>(object)array("Users"=>(array("user_id"=>$user_id,"user_name"=>$Email)))));
I wrote the above code to insert user_id to the array users, after execution i got the result in mongodb shown below
{
"_id" : ObjectId("5702cfd2c693b54008000035"),
"loc1" : "Anapara",
"loc2" : "Puthucurichy",
"loc3" : "Kadinamkulam",
"loc4" : "Kerala",
"loc5" : "India",
"Users" : {
"user_id" : ObjectId("5702cfd2c693b54008000034"),
"user_name" : "chunks@yahoo.com"
}
}
Here the keyword Users is not becoming an array, i mean i want it in this format (value of user in a square bracket):
"Users" :[ {
"user_id" : ObjectId("5702cfd2c693b54008000034"),
"user_name" : "chunks@yahoo.com"}
]
What modification should i do in my php code to put the values in square bracket?