Now I have a "answers" array and I want to remove the first of this array but index item of this array is 1 but not 0. I don't know mongodb has support remove item array and update index array ? My code:
Before remove:
array (
'_id' => new MongoId("52818f9ad069feed198b4567"),
'answers' => array ('0' => array ( 'by' => new MongoId("52818ec2d069fe90058b4567"), 'content' => '<p>Ok, testing<br /> </p> ', 'date' => new MongoInt32(1384222656), ), '1' => array ( 'by' => new MongoId("528192acd21b6310188b4567"), 'content' => 'test', 'date' => new MongoInt32(1384224360), ),),
After remove the first item of answers array
array (
'_id' => new MongoId("52818f9ad069feed198b4567"),
'answers' => array ('1' => array ( 'by' => new MongoId("528192acd21b6310188b4567"), 'content' => 'test', 'date' => new MongoInt32(1384224360), ),),
My result needs
array (
'_id' => new MongoId("52818f9ad069feed198b4567"),
'answers' => array ('0' => array ( 'by' => new MongoId("528192acd21b6310188b4567"), 'content' => 'test', 'date' => new MongoInt32(1384224360), ),),
My English very bad but please help me !
0is normally the first array key, you actually want to remove the second? - scrowler