I have page titles like this:
$pageTitle = "<title>site - {$cat} - {$q} - {$prod} - {$prodName}</title>";
$pageTitle = str_replace(' - - ', ' - ', $pageTitle);
echo $pageTitle;
Sometimes this echos page titles like this:
<title>site - SportingGoods - Airbed - - SportingGoods</title>
When this happens and one of the vars is empty I want to remove the empty the double hyphen with a single one. I thought something like str_replace would work here but it doesn’t.
Thanks in advance.
When one is empty you’ll have two spaces (not one) between the hyphens: