For example, I have this format:
$s_number = "12";
And for this input, I need 0012
as the output:
Another example:
Input $s_number = "3";
Output: 0003
Every time I need 4 digits I would like this to happen.
For example, I have this format:
$s_number = "12";
And for this input, I need 0012
as the output:
Another example:
Input $s_number = "3";
Output: 0003
Every time I need 4 digits I would like this to happen.
It won't be a number (but a string), but you can do that using str_pad. In your examples:
$s_number = str_pad( "12", 4, "0", STR_PAD_LEFT );
$s_number = str_pad( "3", 4, "0", STR_PAD_LEFT );
You can achieve this easily by using phps' printf
<?php
$s_number = '12';
printf("%04d", $s_number);
?>
Hope this helps