我想创建这样的格式: 0000-0000。我已经有了唯一的编号,但我需要将它与我的格式类型合并。
$my_id_unique = '60';
//some function....
//IT SHOULD OUTPUT LIKE THIS
$create_serial = '0000-0060';发布于 2014-02-03 18:48:39
$x = sprintf("%08d",$my_id_unique);
$create_serial = substr($x,0,4).'-'.substr($x,4);发布于 2014-02-03 18:51:10
带着单线盒:
$create_serial = implode('-', str_split(sprintf('%08d', $my_id_unique), 4));发布于 2014-02-03 18:53:23
或者你可以使用焊盘
echo str_pad('60', 9, '0000-0000', STR_PAD_LEFT);https://stackoverflow.com/questions/21535224
复制相似问题