$cc = $this->db->count_all('job_card');
$coun = str_pad($cc,4,STR_PAD_LEFT);
$id = "JI"."-";
$d = date('y') ;
$mnth = date("m");
$customid = $id.$d.$mnth.$coun;
我正在生成和#34; JI-18051000",但我需要它来生成" JI-18050001"。
答案 0 :(得分:1)
您错过了str_pad()
的第三个参数,它指示了填充应该使用的内容。
在这种情况下,您要添加0
,因此您需要将其添加到代码中:
$cc = $this->db->count_all('job_card');
$coun = str_pad($cc, 4, 0, STR_PAD_LEFT); // Updated line to include '0'
$id = "JI"."-";
$d = date('y') ;
$mnth = date("m");
$customid = $id.$d.$mnth.$coun;
答案 1 :(得分:0)
use the following line:
$coun = str_pad($cc,4,0,STR_PAD_LEFT);