Posted
Filed under 프로그래밍/PHP

str_pad

(PHP 4 >= 4.0.1, PHP 5)

str_pad — 문자열을 지정한 길이가 되도록 다른 문자열로 채웁니다

string str_pad ( string $input , int $pad_length [, string $pad_string [, int $pad_type ]] )

<?php
$input 
= "Alien"
;
echo 
str_pad($input, 10);                      
// "Alien     "을 생성.
echo str_pad($input, 10, "-=", STR_PAD_LEFT);  
// "-=-=-Alien"을 생성.
echo str_pad($input, 10, "_", STR_PAD_BOTH);   
// "__Alien___"을 생성.
echo str_pad($input, 6 , "___");               
// "Alien_"을 생성.
?>


iconv

(PHP 4 >= 4.0.5, PHP 5)

iconv — Convert string to requested character encoding

string iconv ( string $in_charset , string $out_charset , string $str )

<?php
$text 
= "안녕";

echo 
'Original : ', $text, PHP_EOL;
echo 
'TRANSLIT : ', iconv("UTF-8", "EUC-KR//TRANSLIT", $text), PHP_EOL;
echo 
'IGNORE   : ', iconv("UTF-8", "EUC-KR//IGNORE", $text), PHP_EOL;
echo 
'Plain    : ', iconv("UTF-8", "EUC-KR", $text), PHP_EOL;

echo 'Plain    : ', iconv("EUC-KR", "UTF-8", $text), PHP_EOL;


?>

2013/07/05 18:22 2013/07/05 18:22