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
$cleanStr = trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", $str)));