如何在PHP中自动增加字符串如ALG030001 [关闭]

i want to split this id ALG030001 but it can't , please help me ,and make it auto increment using PHP like ALG030002,ALG030003,ALG030004,ALG030005,ALG030006 when user submit in database

<?php

    $num = 'ALG030001';

    for ($i = 0; $i < 10; $i ++)
    { 
        echo $num++ . "<br>";
    }


?>

My first thought to solve this problem would get the part of the string that you have and change to something that you can actually increment, an int for example.

<?php
    $string = "ALG030001";
    $chars = substr($string,0,3);

    $number = (int) substr($string,3,strlen($string));

    for ($i=0; $i < 10; $i++) { 
        $string = $chars.$number++; 

        echo $string;
    }
?>

There might be a better way to solve this, but in your case that should do.