Hello,

Please advise how to remove white spaces before and after a sentence only. Example: " This is a sentence. " should be "This is a sentence."

Thanks.

Thank you for the link. The following code is working:

<?php
$str1 = "   This is a sentence.  ";
$str2 = ltrim(rtrim($str1," ")," ");
?>
$str2 = trim($str1); // does the same
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.