In this blog, We will be going to learn about how to remove whitespace from the beginning and end of a string using PHP. This is very simple because PHP provides functions that will be going to help in removing whitespace.
We will be using trim() function to remove whitespace from the beginning and end of the string.
Let's start with examples,
Code:
<?php
$myString = " This is thecodingdev.com ";
$newString = trim($myString);
print_r($newString);
?>
Output:
This is thecodingdev.com
I hope you understood this. If you have any doubts, let me know in the comments.
0 Comments