hi guys,
I am confused from the result of the following code: I can't get my expected result:
$arrX = array('a'=>array('val'=>10),'b'=>array('val'=>20), 'c'=>array('val'=>30));
foreach( $arrX as &$DataRow )
{
$DataRow['val'] = $DataRow['val'] + 20;
}
foreach( $arrX as $DataRow )
{
echo '<br />val: '.$DataRow['val'].'<br/>';
}
Output: 30, 40, 40
Expected: 30, 40, 50
But again if i make small chage it works fine,
$arrX = array('a'=>array('val'=>10),'b'=>array('val'=>20), 'c'=>array('val'=>30));
foreach( $arrX as &$DataRow )
{
$DataRow['val'] = $DataRow['val'] + 20;
}
foreach( $arrX as &$DataRow )
{
echo '<br />val: '.$DataRow['val'].'<br/>';
}