PHP 찹() 함수
예시
문자열의 오른쪽 끝에서 문자 제거:
<?php
$str = "Hello World!";
echo $str . "<br>";
echo chop($str,"World!");
?>
정의 및 사용
chop() 함수는 문자열의 오른쪽 끝에서 공백이나 기타 미리 정의된 문자를 제거합니다.
통사론
chop(string,charlist)
매개변수 값
Parameter | Description |
---|---|
string | Required. Specifies the string to check |
charlist | Optional. Specifies which characters to remove from the string. The following characters are removed if the charlist parameter is empty:
|
기술적 세부 사항
반환 값: | 수정된 문자열을 반환 |
---|---|
PHP 버전: | 4+ |
변경 로그: | charlist 매개변수는 PHP 4.1.0에 추가되었습니다 . |
더 많은 예
예시
문자열의 오른쪽 끝에서 줄 바꿈(\n)을 제거합니다.
<?php
$str = "Hello World!\n\n";
echo $str;
echo chop($str);
?>
위 코드의 HTML 출력은 (소스 보기):
<!DOCTYPE html>
<html>
<body>
Hello World!
Hello World!
</body>
</html>
위 코드의 브라우저 출력은 다음과 같습니다.
Hello World! Hello World!
❮ PHP 문자열 참조