How to Trim Blanks from a String Using PHP?

How to Expose and Route to a Resource?
How to Expose and Route to a Resource?

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.

इसे भी पढ़े – C++ Language कैसे सीखें?

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *