str_pad - 문자열을 다른 문자열로 특정 길이로 채 웁니다 . 정보
PHP str_pad - 문자열을 다른 문자열로 특정 길이로 채 웁니다 .본문
str_pad - 문자열을 다른 문자열로 특정 길이로 채 웁니다 .
설명 ¶
string str_pad ( string $input , int $pad_length [, string $pad_string= "" [, int $pad_type= STR_PAD_RIGHT ]])
이 함수는 input왼쪽, 오른쪽 또는 양쪽에 채워진 문자열을 지정된 채우기 길이로 반환합니다. 선택적 인수 pad_string가 제공되지 않으면, input공백으로 채워지고, 그렇지 않으면 pad_string 최대 한도의 문자로 채워집니다 .
매개 변수 ¶
input
입력 문자열.
pad_length
of의 값 pad_length이 음수이거나 입력. 자 열의 길이보다 작거나 같으면 패딩이 일어나지 않고 input리턴됩니다.
pad_string
참고 :
는 pad_string패딩 문자 필요한 수의 균등에 의해 분할 할 수없는 경우 절단 할 수 pad_string의 길이.
pad_type
옵션 인수는 pad_type할 수있다 STR_PAD_RIGHT, STR_PAD_LEFT또는 STR_PAD_BOTH. if pad_type가 지정되지 않으면이 값은 것으로 가정합니다 STR_PAD_RIGHT.
반환 값 ¶
패딩 된 문자열을 반환합니다.
예 ¶
Example # 1 str_pad () 예제
<?php
$input = "Alien";
echo str_pad($input, 10); // produces "Alien "
echo str_pad($input, 10, "-=", STR_PAD_LEFT); // produces "-=-=-Alien"
echo str_pad($input, 10, "_", STR_PAD_BOTH); // produces "__Alien___"
echo str_pad($input, 6, "___"); // produces "Alien_"
echo str_pad($input, 3, "*"); // produces "Alien"
?>
0
댓글 0개