Hi there im trying to update a nested array I have done some research and have come up with the following question but the answer isnt quite clear on how to update where x = this.
LINK How to updated nested array
$yourArray["experience"][1]["from"] = 2006;
That line looks like what I need but I need to figure out how to use the update part of it, this is my post script for my form.
$ID = $_POST["id"];
$NAMESTATE = $_POST["name"];
$REASON = $_POST["reason"];
require ('mongo.php');
if ($WISHNAMESTATE == "" and $ID == "")
{
echo("OOPS SOMETHING WENT WRONG!");
exit();
}
else
{
$m->update(array('_id' => $ID),(array('fields.NameState._0' => $NAMESTATE)));
header("refresh:0;url=names_test.php");
My db looks like this.
array(
"_id"=>100000005,
"dclass"=>"Distributed",
"fields"=>array(
"Name"=>array(
"_0"=>"Testing",
),
"NameState"=>array(
"_0"=>"PENDING",
),
'setName': {
'_0': 'test name'
So what this post needs to do is take the value NAMESTATE and update that field in the document with the matching ID, Please let me know if I am on the right track here.