What is chop function in php?
(PHP 4, PHP 5, PHP 7, PHP 8) Show chop — Alias of rtrim() DescriptionThis function is an alias of: rtrim(). Notes
Kubo2 ¶ 7 years ago
JumpIfBelow ¶ 7 years ago
krkbpk at gmail dot com RamaKrishna Kothamasu ¶ 9 years ago
rahuls8730 at gmail dot com ¶ 13 years ago
anon at mailinator dot com ¶ 15 years ago
func_get_args() as $b) {push($ar,$b[strlen($b)-1]); View Discussion Improve Article Save Article View Discussion Improve Article Save Article The chop() in PHP is used to remove white spaces or any other specified characters from the end of a string. Syntax: string chop($string, $character) Parameters: This function accepts two parameters as shown in the above syntax and are described below:
Return Value: The return type of the chop() function is string. It returns the string after removing the specified characters from the end. Program 1: In the below program a string is initialized as hello geeks!, by using chop() function the characters – ‘s’ and ‘!’ are removed from the end of the string.
Output: Hello Geeks! Hello Geek Program 2: In the below program, since no character parameter is mentioned. Then automatically the newlines will be removed from the given string.
Output: Hello Geeks! best wishes Hello Geeks! best wishesHello Geeks! best wishes Reference: How do I delete a word in PHP?PHP str_replace() Function. Replace the characters "world" in the string "Hello world!" with "Peter": ... . Using str_replace() with an array and a count variable: $arr = array("blue","red","green","yellow"); ... . Using str_replace() with fewer elements in replace than find: $find = array("Hello","world");. What is PHP Ltrim?Definition and Usage. The ltrim() function removes whitespace or other predefined characters from the left side of a string. Related functions: rtrim() - Removes whitespace or other predefined characters from the right side of a string.
What is substring PHP?The substr() is a built-in function of PHP, which is used to extract a part of a string. The substr() function returns a part of a string specified by the start and length parameter. PHP 4 and above versions support this function.
Which of the following is an alias for the chop () PHP function?The chop() function is used to remove the whitespaces and other predefined characters from the right side of a string. This function is an alias of rtrim() function.
|