Title: zeroise
Published: April 25, 2014
Last modified: February 24, 2026

---

# zeroise( int $number, int $threshold ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#wp--skip-link--target)

Add leading zeros when necessary.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#description)󠁿

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.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#parameters)󠁿

 `$number`intrequired

Number to append zeros to if not greater than threshold.

`$threshold`intrequired

Digit places number needs to be to not have zeros added.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#return)󠁿

 string Adds leading zeros to number if needed.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#source)󠁿

    ```php
    function zeroise( $number, $threshold ) {
    	return sprintf( '%0' . $threshold . 's', $number );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/formatting.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/formatting.php#L2788)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/formatting.php#L2788-L2790)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Locale::get_month_genitive()](https://developer.wordpress.org/reference/classes/wp_locale/get_month_genitive/)`wp-includes/class-wp-locale.php` |

Retrieves translated version of month genitive string.

  | 
| [export_date_options()](https://developer.wordpress.org/reference/functions/export_date_options/)`wp-admin/export.php` |

Creates the date options fields for exporting a given post type.

  | 
| [WP_List_Table::months_dropdown()](https://developer.wordpress.org/reference/classes/wp_list_table/months_dropdown/)`wp-admin/includes/class-wp-list-table.php` |

Displays a dropdown for filtering items in the list table by month.

  | 
| [touch_time()](https://developer.wordpress.org/reference/functions/touch_time/)`wp-admin/includes/template.php` |

Prints out HTML form date elements for editing post or comment publish date.

  | 
| [media_upload_library_form()](https://developer.wordpress.org/reference/functions/media_upload_library_form/)`wp-admin/includes/media.php` |

Outputs the legacy media upload form for the media library.

  | 
| [antispambot()](https://developer.wordpress.org/reference/functions/antispambot/)`wp-includes/formatting.php` |

Converts email addresses characters to HTML entities to block spam bots.

  | 
| [get_calendar()](https://developer.wordpress.org/reference/functions/get_calendar/)`wp-includes/general-template.php` |

Displays calendar with days that have posts as links.

  | 
| [wp_title()](https://developer.wordpress.org/reference/functions/wp_title/)`wp-includes/general-template.php` |

Displays or retrieves page title for all areas of blog.

  | 
| [WP_Locale::get_month()](https://developer.wordpress.org/reference/classes/wp_locale/get_month/)`wp-includes/class-wp-locale.php` |

Retrieves the full translated month by month number.

  | 
| [get_month_link()](https://developer.wordpress.org/reference/functions/get_month_link/)`wp-includes/link-template.php` |

Retrieves the permalink for the month archives with year.

  | 
| [get_day_link()](https://developer.wordpress.org/reference/functions/get_day_link/)`wp-includes/link-template.php` |

Retrieves the permalink for the day archives with year and month.

  |

[Show 6 more](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/zeroise/?output_format=md#comment-content-1508)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/zeroise/#comment-1508)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fzeroise%2F%23comment-1508)
    Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fzeroise%2F%23comment-1508)
 4. **Leading zeros on number of comments**
 5.     ```php
        $comno = get_comments_number();
        echo zeroise( $comno, 2 );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fzeroise%2F%3Freplytocom%3D1508%23feedback-editor-1508)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fzeroise%2F)
before being able to contribute a note or feedback.