PHP

PHP Menu

PHP

chop() Function - Definition, Syntax, Parameters, Examples

Definition

The chop() function strips whitespace (or other characters) from the end of a string. Alias of rtrim() function.

Syntax

chop(string, charlist)

Parameters

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:
"\0" - null
"\t" - tab
"\n" - new line
"\x0B" - vertical tab
"\r" - carriage return
" " - ordinary white space

Example

<?php
$str = "Hello World!"; echo chop($str, "World!");

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods