Advertisements

zeroise

Definition:
function zeroise($number, $threshold) {}

Add leading zeros when necessary.
If you set the threshold to ‘4’ and the number is ’10’, then you will get back ‘0010’. If you set the threshold to ‘4’ and the number is ‘5000’, then you will get back ‘5000’.

Parameters

  • mixed $number: Number to append zeros to if not greater than threshold.
  • int $threshold: Digit places number needs to be to not have zeros added.

Return values

returns:Adds leading zeros to number if needed.

Source code

function zeroise($number, $threshold) {

	return sprintf('%0'.$threshold.'s', $number);

}

4289

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: