I am needing to get the sum value of two array variables.
Here's my code:
for($i=0;$i<sizeof($check);$i++){
for($j=0;$j<sizeof($item_rec);$j++){
for($k=0;$k<sizeof($last_item_rec);$k++){
//TOTAL_VAR = $item_rec[$j] + $last_item_rec[$k];
$query=mysqli_query($con,"UPDATE tblstock
SET
rec_qty='{{SUM VALUE HERE}}'
WHERE id = '$check[$i]'")
or die(mysqli_error($con));
}
}
}//end for loop
As you can see in the comment, I don't know what variable will I declare to sum each array value of variable $item_rec and $last_item_rec.
$on the start like$TOTAL_VARand cast the array value like$TOTAL_VAR = (int)$item_rec[$i] + (int)$last_item_rec[$i]or you can use float if the value is decimal.