Please advise how to remove white spaces before and after a sentence only. Example: " This is a sentence. " should be "This is a sentence."
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
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.