Potresti fare una cosa del genere,magari con un ciclo (preferibilmente while)

Codice PHP:

$input  
=  050001
$string 
"M" $input;
$input++;