Mobile app version of vmapp.org
Login or Join
Dunderdale272

: Upper case beginnning letters of a domain using HTTP_HOST For the past couple of months I've been thinking of a website I'd like to launch for a small community of people in my neighborhood.

@Dunderdale272

Posted in: #CaseSensitive #Domains #Http #Title

For the past couple of months I've been thinking of a website I'd like to launch for a small community of people in my neighborhood. The concept is just a simple tag board to help the community know what's happening in their neighborhood. As a result, I've succeeded in that.

However as time passed more and more people sort of wanted to test the same concept on their communities but with their own branding domain. Which is why I've bought two domains and each point to the same website.

Thing is, I'd like to make it so that the website's URLs are capitalized in the beginning sentences like: "WisteriaLane.com" or "PlumasStreet.com"

I've succeeded in making the website's title use the following:

<?=str_replace('www.', '', $_SERVER['HTTP_HOST']);?>


However, when accessing the website, the domain name is lowercase and that means the title as well.

If anyone knows how to solve this, I'd be entirely grateful.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Dunderdale272

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

You can't "automatically" capitalize (ie. CamelCase) a string of the form "wisterialane.com" without PHP having access to a database of words (which it doesn't have, unless you write this into the code yourself).

However, if your domains are a specific format with specific words, which they seem to be, then this simplifies the problem. eg. Capitalise the first letter and any of the words "lane", "street", etc.

For example:

PHP:

function toCamelCase($str) {
// Words to convert/replace (ie. capitalise)
$words = array (
'www.' => '', // Special case
'street' => 'Street',
'lane' => 'Lane',
);

// Ensure all lowercase with uppercase first char
$str = ucfirst(strtolower($str));

// Convert any other words
$str = str_replace(array_keys($words),array_values($words),$str);
return $str;
}


HTML:

<?=toCamelCase($_SERVER['HTTP_HOST'])?>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme