Menu

Add Topic

programming

waiting answer July 28, 2021

How to remove white space from the end of a string in PHP

Answers
June 13, 2021

The PHP function rtrim is used to remove white space from the end of the string.

Let's check the following example to understand how this function actually works

     <?php
        $string = 'Welcome to America     ';
        echo strlen($string); // Outputs: 23
        $rtrim_str = rtrim($string);
        echo strlen($rtrim_str); // Outputs: 18
    ?>
0 0

Please Login to Post the answer

Leave an Answer