In your last foreach
loop,
$tprofit=array();
foreach($capacity as $key => $value){
foreach($profit as $k => $v){
$newkey="${key},${k}";
print_r($distance[$newkey]);
$tprofit[$newkey]= $v - $distance[$newkey];
}
}
The correct one is :
$tprofit=array();
foreach($capacity as $key => $value){
foreach($profit as $k => $v){
$newkey="{$key},{$k}";
print_r($distance[$newkey]);
$tprofit[$newkey]= $v - $distance[$newkey];
}
}
You were assigning wrong string to $newkey
. Try it now, and update your question if more errors pop up.