Thanks for the prompt reply.
Actually my code flow is as follows:
//GATHER VALUES//
$treetxt = '';
$treeroot = '';
$getrel = mssql_query('select * from product_rev_det where vendor_ccode=151 and yr=2005 and status=1 order by ref_ctype, ref_ccode');
while($gotrel = mssql_fetch_array($getrel))
{
$relation[$gotrel[id]] = array ('id' => $gotrel[id],
'rccode' => $gotrel[ccode],
'rccode_rel' => $gotrel[ccode_relation],
'rvccode' => $gotrel[vendor_ccode],
'rvsname' => $gotrel[vendor_sname],
'rpmainid' => $gotrel[prod_mainid],
'rpcat' => $gotrel[prod_cat],
'rpnm' => $gotrel[prod_nm],
'rrccode' => $gotrel[ref_ccode],
'rrcname' => $gotrel[ref_cname],
'rrctype' => $gotrel[ref_ctype],
'rrevpcent' => $gotrel[rev_pcent],
'rused' => '0');
}
function findDistributor($arr, $fld1, $val1)
{
while (list ($key, $val) = each ($arr)){
if ($arr[$key][$fld1] == $val1) {
$target[$key] = $arr[$key];
$relation[$key]['rused'] = '1';
}
}
return $target;
}
Now in this code you can see that I am generating the relation array in the main page which contains a function. I pass the array to a array variable in the function but within the function i use the same name $relation which was declared outside to update the element of the array generated previously.