Menu

Add Topic

programming

waiting answer July 28, 2021

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

Answers
June 13, 2021

The PHP function ltrim() is used to remove white space from the beginning of a string.

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

     <?php
        $string = '     Welcome to America';
        echo strlen($string); // Outputs: 16 
        $ltrim_str = ltrim($string);
        echo strlen($ltrim_str); // Outputs: 12
     ?>
0 0

Please Login to Post the answer

Leave an Answer