Fri, 17 May 2024


How to strip the whitespaces at the beginning and the end of a string?

By: Peter, NetArt Media
Thu, 30 July 2020

You may use the special PHP function trim.

<?php

$myText=" car ";

echo trim($myText);

?>

will display:

"car"


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox