I'm not sure what you wanna gain here, either Uxxxxx or U00000x. But I guess you mean the first case, so:
$userid = __what_ever__;
$prefix = "U";
for($i = 0; $i < 5 - strlen((String)$userid); $i++) {
$prefix .= '0';
}
$userid = $prefix . $userid;
and for the what ever part, first get the last row of users, and do this to the user id part(ex U00456):
$userid = substr($userid, 1);
$userid = intval($userid)++;
Although it's good practice not to assign everything to the same $userid