<?php
$autoId = 11; /* this is the auto id from the database */
$id = "AZ2D20D7S99"; /* this is the user input */
/* find the trailing number and store it in $number */
preg_match("/[^\d]+(\d+)$/", $id, $matches);
$number = $matches[1];
/* increase the number by the database id */
$newNumber = $number + $autoId;
/* replace the old number with the new number */
echo preg_replace("/\d+$/", $newNumber, $id);
?>