Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




zeroise [ WordPress Function ]

zeroise ( $number, $threshold )
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.
Returns:
  • (string) Adds leading zeros to number if needed.
Defined at:



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'.

Uses sprintf to append the amount of zeros based on the $threshold parameter and the size of the number. If the number is large enough, then no zeros will be appended.

Source


<?php
function zeroise($number$threshold) {
    return 
sprintf('%0'.$threshold.'s'$number);
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics