Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8282807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:30:21+00:00 2026-06-08T10:30:21+00:00

I have tutorial 1 how to make this tutorial 21 how to make this

  • 0

I have

  • tutorial 1 how to make this
  • tutorial 21 how to make this
  • tutorial 2 how to make this
  • tutorial 3 how to make this

and i need

  • tutorial 01 how to make this
  • tutorial 21 how to make this
  • tutorial 02 how to make this
  • tutorial 03 how to make this

so i can order them properly. (adding leading 0 when single digit is found)

What would be a php method to convert?

thanks in advance

note-please make sure that it identifies the single digit numbers only first and then add the leading zero

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:30:23+00:00Added an answer on June 8, 2026 at 10:30 am

    If it is coming from a DB, this is the way to do it on a sql query:

    lpad(yourfield, (select length(max(yourfield)) FROM yourtable),'0') yourfield
    

    This is will get the max value in the table and place the leading zeros.

    If it’s hardcoded (PHP), use str_pad()

    str_pad($yourvar, $numberofzeros, "0", STR_PAD_LEFT);
    

    This is a small example of what I did on a online php compiler, and it works…

    $string = "Tutorial 1 how to";
    
    $number = explode(" ", $string); //Divides the string in a array
    $number = $number[1]; //The number is in the position 1 in the array, so this will be number variable
    
    $str = ""; //The final number
    if($number<10) $str .= "0"; //If the number is below 10, it will add a leading zero
    $str .= $number; //Then, add the number
    
    $string = str_replace($number, $str, $string); //Then, replace the old number with the new one on the string
    
    echo $string;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi 2 all guys i make all like in tutorial. But i have stopped
Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I have found a Tutorial here on how to implement drag and drop in
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I have followed this tutorial here as mentioned exactly I now try to run
This tutorial here shows how to add toolchains to Qt Creator. I didn't need
I have been trying to teach myself MEF, starting with this tutorial: http://blogs.msdn.com/b/brada/archive/2008/09/29/simple-introduction-to-composite-applications-with-the-managed-extensions-framework.aspx There
I have been trying to make this work for a long time now. In
I have been researching this problem for a while now and I just can't
I have read this tutorial and I am familiar with simple databinding. But how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.