PHP has build function trim() to remove the white space from a given string.
trim() function will remove whitespace including non-breaking spaces, newlines, and tabs from the beginning and end of the string. It will not remove whitespace occurs in the middle of the string
|
$my_str = ' Welcome to PHP Programing '; |
How to check string has whitespace or not in php?
To check whether a string has no whitespace, use the preg_match() in PHP
Let's check example
|
This will return output like below
The name (PHP Laravel Framework) has the space
|