PHP str_pad()

1 개요[ | ]

PHP str_pad()
PHP
Copy
$s = 'Hello';
echo str_pad($s, 8, '*', STR_PAD_LEFT);
Loading
PHP
Copy
$s = 'Hello';
echo str_pad($s, 8, '*', STR_PAD_RIGHT);
Loading
PHP
Copy
$input = "Alien";
echo str_pad($input, 10)."\n";                      // produces "Alien     "
echo str_pad($input, 10, "-=", STR_PAD_LEFT)."\n";  // produces "-=-=-Alien"
echo str_pad($input, 10, "_", STR_PAD_BOTH)."\n";   // produces "__Alien___"
echo str_pad($input,  6, "___")."\n";               // produces "Alien_"
echo str_pad($input,  3, "*")."\n";                 // produces "Alien"
Loading

2 같이 보기[ | ]

3 참고[ | ]