I want to remove extra spaces present in my string. I have tried trim,ltrim,rtrim and others but non of them are working and even trie
trim
ltrim
rtrim
If you want to remove multiple spaces within a string you can use the following:
$testStr = " Hello Welcome to India "; $ro = trim(preg_replace('/\s+/', ' ', $testStr));