Jump to content

convert single digits to double digits in string


vzwhaley

Recommended Posts

Does anybody know of a good way to convert single digits, i.e. 1, 2, 3, 4, in a string to double double digits, i.e. 01, 02, 03, 04. I used the following code, but it places a 0 in front of numbers like 10, 11, 12, etc. Any help would be appreciated.

[code]
$Section = $temp[$i];
$search = array("1", "2", "3", "4", "5", "6", "7", "8", "9");
$replace = array("01", "02", "03", "04", "05", "06", "07", "08", "09");
$Section3 = str_replace($search, $replace, $Section); [/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.