PHP - How do I add a key => value to a specific part of an multidimensional array?

Hyperz

New Member
How would I insert a key => value pair into the midst of a nested array?example:\[code\]array 1 => string 'a' (length=1) 2 => string 'b' (length=1) 3 => array 'this' => string 'that' (length=4) 'meh' => string 'foo' (length=3) 'blah' => array 'a' => int 1 'b' => int 2 4 => array 'this' => string 'that' (length=4) 'meh' => string 'foo' (length=3) 'blah' => array 'a' => int 1 'b' => int 2\[/code\]How would I add \[code\]x=>1\[/code\] to every second level of array... so I would get this:\[code\] array 1 => string 'a' (length=1) 2 => string 'b' (length=1) 3 => array 'this' => string 'that' (length=4) 'meh' => string 'foo' (length=3) 'blah' => array 'a' => int 1 'b' => int 2 'x' => int 1 //Here's the added bit 4 => array 'this' => string 'that' (length=4) 'meh' => string 'foo' (length=3) 'blah' => array 'a' => int 1 'b' => int 2 'x' => int 1 //Here's the added bit\[/code\]
 
Back
Top