Problem:- How to Trim Blanks from a String Using PHP?, You want to remove white-space from beginning or end of string. For Example, You want to clean up user input before validating it.
Solution – Trimming Blanks From a String Using PHP
<?php $string = " Hindi Alerts Author "; $both_trim_string= trim($string); $start_trim_string= ltrim($string); $end_trim_string= rtrim($string); ?>
How it Work?
- ltrim() function remove white-space form beginning of string.
- rtrim() function remove white-space from end of a string.
- trim() function remove white-space from both side of a string.
Leave a Reply