如何使用PHP / Codeigniter中的给定序列生成唯一的票号

I need to generate unique ticket number using the given sequence which is given format C0000000001
C0000000002
C0000000003
C0000000004
C0000000005
C0000000006
C0000000007
C0000000008
C0000000009
C0000000010
C0000000011

You can try using str_pad

Code

$max = 9;
for($x = 1; $x <= 11; $x++){

    echo 'C' .str_pad('', $max - strlen((string) $x), '0', STR_PAD_LEFT) . $x . "<br />";
}

Result

C000000001
C000000002
C000000003
C000000004
C000000005
C000000006
C000000007
C000000008
C000000009
C000000010
C000000011