Sometimes it is needed to make a string to a certain length specially for the ticketing software. Let a ticket is going to place by someone to a specific department(let department is support), we need to give him a ticket id something humanize and its length will be always of 10 characters. We want to give him a ticket id something like
Where SU is the department name prefix and 1 is the id of this entry. On that case the php function str_pad is very usefull. just follow the following code which is very simple:
$entry_id=1; $dept_prefix = 'SU'; $padded_id = str_pad($entry_id,8,'0',STR_PAD_LEFT); $ticket_id = $dept_prefix.$padded_id;
Love this function!