例子 1. str_pad() example<?php
$input = "Alien";
print str_pad($input, 10);                      // produces "Alien     "
print str_pad($input, 10, "-=", STR_PAD_LEFT);  // produces "-=-=-Alien"
print str_pad($input, 10, "_", STR_PAD_BOTH);   // produces "__Alien___"
print str_pad($input, 6 , "___");               // produces "Alien_"
?>
 

解决方案 »

  1.   

    $str = sprintf("%010d",$number); //转成10为长
      

  2.   

    唠叨兄的是正确的
    volca的要是这个整数超出了他指定的这个长度,就不能处理了
      

  3.   

    php语法难道能叫‘C风格’吗?他本来就是用C语法,呵呵!
      

  4.   

    to Cain(一苇渡江):你去试试看超过长度能不能处理?
    <?php
    $input = "1111111111111111111111111111";
    echo str_pad( $input, 10 , '0' , STR_PAD_LEFT);  
    ?>-___-