2011-05-04

php 將數字補零 使用str_pad

http://tw2.php.net/str_pad
string str_pad ( string $input , int $pad_length [, string $pad_string = " " [, int $pad_type = STR_PAD_RIGHT ]] )


<?php
$input 
"Alien";
echo 
str_pad($input10);                      // produces "Alien     "echo str_pad($input10"-="STR_PAD_LEFT);  // produces "-=-=-Alien"echo str_pad($input10"_"STR_PAD_BOTH);   // produces "__Alien___"echo str_pad($input"___");               // produces "Alien_"?>

沒有留言: