如何格式化12个字符?

I have the price value 172.5. but i need to format it 12 characters.

eg. 0000000172.00 eg2. 0000001500.00 eg3. 0000001298.30 eg4. 0000047172.50

Thanks u. need to format with php.

Try to use this one

echo sprintf("%013.2f", $num);

Try this code $price = 172.5; $zero_pad = "000000000000"; $diff = 12 - strlen($price); $zero = substr($zero_pad, 0,$diff); $price = $zero.$price;