bhe, se devi solo incrementare le ultime 4 cifre, ti basta dividere la stringa prendendo solo 0001, utilizzando:Codice PHP:
<?
$stringa = "M050001";
$cifre = substr($stringa,2,5);
$cifre++;
if ($cifre < 10) $cifre = "000".$cifre;
if ($cifre < 100) $cifre = "00".$cifre;
if ($cifre < 1000) $cifre = "0".$cifre;
$stringa_aggiornata = substr($stringa,0,2).$cifre;
echo $stringa_aggiornata;
?>