Replace Dash with Space in PHP
This str_replace does the job:
$string = str_replace("-", " ", $string);
Also, you can make it as a function.
function replace_dashes($string) {
$string = str_replace("-", " ", $string);
return $string;
}
Then you call it:
$varcity = replace_dashes($row[website]);
<div><a href="http://www.envisionforce.com/local/'.$row[website].'-seo-services">'.ucwords($varcity).'</a></div>
<?php
echo '<div><a href="http://www.envisionforce.com/local/'.$row[website].'-seo-services">'.ucwords(str_replace("-"," ",$row[website])).'</a></div>';
In the above example you can use str_replace()
to replace hyphens with spaces to create separate words. Then use ucwords()
to capitalize the newly created words.
http://php.net/manual/en/function.str-replace.php
http://php.net/manual/en/function.ucwords.php