1

How I can modify nested array e.g.

`array (
  '_id' => new MongoId("4e3a81376155a9d439000000"),
  'name' => 'Umar',
  'password' => 'rose',
  'email' => 'umar@ibm.com',
  'experience' => 
  array (
    0 => 
    array (
      'company' => 'ibm',
      'from' => '2005',
      'to' => '2007',
    ),
    1 => 
    array (
      'company' => 'sun',
      'from' => '2007',
      'to' => '2009',
    ),
    2 => 
    array (
      'company' => 'oracle',
      'from' => '2009',
      'to' => 'still',
    ),
  ),
)
`

Now i want to update company sun from value existing value is 2007 I want to change with 2006. I am using PHP.

Would you please help.

Best Regards,

Umar

Umar Draz
  • 131
  • 1
  • 3
  • 9

1 Answers1

1

Quite simply:

$yourArray["experience"][1]["from"] = 2006;

laurent
  • 88,262
  • 77
  • 290
  • 428