We always get maximum sum if we replace 5 with 6.
$ maxSum = replaceDig ( $ x1 , 5 , 6 ) + replaceDig ( $ x2 , 5 , 6 ) ; echo " Minimum ▁ sum ▁ = ▁ " , $ minSum , " STRNEWLINE " ; echo " Maximum ▁ sum ▁ = ▁ " , $ maxSum ; }