Php foreach over an array and assignment of this array?

Just call $cell by reference like this: foreach($array as &$cell) {...} And it should retain the value. Passing by reference.

Yes! Thank you! – Nicolas Thery Dec 18 '11 at 16:06.

When you iterate over the array, $cell is a copy of the value, not a reference so changing it will not effect the value in the array. You should either use & to make the $cell a reference: foreach ($array as &$cell) { if ($cell"type" == "type_list") { $cell"list" = $anObject; error_log(print_r($cell, TRUE), 0); } error_log(print_r($array, TRUE), 0); Or access the array items directly using an index. Foreach ($array as $i => $cell) { if ($array$i"type" == "type_list") { $array$i"list" = $anObject; error_log(print_r($array$i, TRUE), 0); } error_log(print_r($array, TRUE), 0).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions