我这这样的一组ID字符串
10            
1010
10122233我想转换成 下面的整型数10 000 000 000
10 100 000 000
10 122 233 000
请问一下,这样的算法,我怎么写一下。
最好是有一个方法。

解决方案 »

  1.   

    $s = '10122233';
    $s = str_pad($s, 11, '0');
    $t = number_format($s);
    echo join(' ', explode(',', $t));
      

  2.   


    $str1='10';
    $str2='1010';
    $str3='10122233';
    //10 000 000 000
    //10 100 000 000
    //10 122 233 000
    echo str_pad($str1, 11,'0').'<Br>';
    echo str_pad($str2, 11,'0').'<br>';
    echo str_pad($str3, 11,'0').'<Br>';
      

  3.   

    str_pad(string,length,pad_string,pad_type)//str_pad() 函数把字符串填充为指定的长度。