Syntax :
string chop (string, charlist);
chop function will remove predefined characters or specified characters in charlist if any from the right end of a string. This function is an alias of- rtrim() function.
string – String to check.
charlist – Optional. This is optional parameter, If any value is provided, then specified characters will be removed from right of a string.
The following characters are removed if the charlist parameter is empty:
This will return the string after removing specified characters in the charlist or predefined characters from right of a string.
$strExample = chop("Hi from tutorialmines.net! ");
echo($strExample);
In above example ,We have string of “Hi from tutorialmines.net! “. So, when we apply chop function. This will remove all ” ” (ordinary white space) from right of a input string.
Now Output will become –
Hi from tutorialmines.net!
If you want to remove string ” chop – PHP String Functions” from the right hand side of a string. See below example for doing it.
$strExample = ("Hi from tutorialmines.net! chop - PHP String Functions");
echo $strExample . "<br>";
echo chop($strExample,"chop - PHP String Functions");
In above example ,We have string of “Hi from tutorialmines.net! chop – PHP String Functions”. So, when we apply chop function. This will remove string “chop – PHP String Functions” from right of a input string.
Output will be like below:
Hi from tutorialmines.net! chop - PHP String Functions
Hi from tutorialmines.net!
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…