advanced code snippet search
andreiabohner on 12/27/09
Pad Left zeros Fill padding
12/27/09 09:39pm12/27/09 09:38pm12/27/09 09:34pm
1 person have marked this snippet as a favorite
seloh77
fill string with left zeros
$s = "2";$maxLen = 4;echo str_pad($s, $maxLen, "0", STR_PAD_LEFT); // "0002" // or echo printf("[%04s]\n", $s); // 0002
Report this snippet Tweet
Comment:
You need to login to post a comment.