How to remove white space from the beginning of a string in PHP
ltrim()
You can use the PHP ltrim() function to strip whitespace from the beginning of a string.
Let's take a look at an example to understand how this function really works:
<?php $my_str = ' Hello World!'; echo strlen($my_str); // Outputs: 16 $trimmed_str = ltrim($my_str); echo strlen($trimmed_str); // Outputs: 12 ?>
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Use the PHP
ltrim()functionYou can use the PHP
ltrim()function to strip whitespace from the beginning of a string.Let's take a look at an example to understand how this function really works:
need an explanation for this answer? contact us directly to get an explanation for this answer