Removing Leading and Trailing Spaces in PHP


How To Remove Leading and Trailing Spaces from User Input Values?



If you are taking input values from users with a Web form, users may enter extra spaces at the beginning and/or the end of the input values. You should always use the trim() function to remove those extra spaces as shown in this PHP script:

$name = $_REQUEST("name");
$name = trim($name);
# $name is ready to be used...


Finding a Substring in PHP

Remove Trailing New Line Character in PHP

PHP Built-in Functions for Strings

⇑⇑ PHP Tutorials

2016-10-13, 2365🔥, 0💬