i try to replace value of arrays in same group with that one has the value but its not work correctly you can see in the code below why?
function trace($val)
{
echo "pre";
print_r($val);
echo "pre";
}
$rows = array(
array('a'=>'33333','b'=>'#3333','group'=>1),
array('a'=>'','b'=>'','group'=>1),
array('a'=>'','b'=>'','group'=>2),
array('a'=>'5555','b'=>'#werwe','group'=>2)
);
trace($rows);
$oldGroupId = -1;
foreach($rows as &$row)
foreach($row as $column=>$fieldValue)
{
if($row['group']!=$oldGroupId)
${$row['group']}[$column]=0;
if( !is_null( $row[$column] ) )
${$row['group']}[$column]=$row[$column];
//@ in this place try to point to my dynamick variable pointer for change if change value frome previuse all value in array cahnge
$row[$column] = & ${$row['group']}[$column];
}
trace($rows);
?>
çıktı değeri:
Array
(
[0] => Array
(
[a] => 33333
[b] => #3333
[group] => 1
)
[1] => Array
(
[a] =>
[b] =>
[group] => 1
)
[2] => Array
(
[a] =>
[b] =>
[group] => 2
)
[3] => Array
(
[a] => 5555
[b] => #werwe
[group] => 2
)
)
Array
(
[0] => Array
(
[a] =>
[b] =>
[group] => 1
)
[1] => Array
(
[a] =>
[b] =>
[group] => 1
)
[2] => Array
(
[a] => 5555
[b] => #werwe
[group] => 2
)
[3] => Array
(
[a] => 5555
[b] => #werwe
[group] => 2
)
)
değeri beklenen:
Array
(
[0] => Array
(
[a] => 33333
[b] => #3333
[group] => 1
)
[1] => Array
(
[a] => 33333
[b] => #3333
[group] => 1
)
[2] => Array
(
[a] => 5555
[b] => #werwe
[group] => 2
)
[3] => Array
(
[a] => 5555
[b] => #werwe
[group] => 2
)
)
güncelleme:
Bu işe değilse bana bu nedenle başka bir yol söyleyebilir misiniz?