Do school mathematics , compute sum of current digits and carry
$ sum = ( ( ord ( $ str1 [ $ i ] ) - ord ( '0' ) ) + ( ( ord ( $ str2 [ $ i + $ diff ] ) - ord ( '0' ) ) ) + $ carry ) ; $ str3 . = chr ( $ sum % 10 + ord ( '0' ) ) ; $ carry = ( int ) ( $ sum / 10 ) ; }