![]() |
Domain Keyword
I want to fetch the keyword from the domain.
Currently, my code works with www.domain.com but doesn't work with www.domain.co.uk and www.domain.com.uk or any domain that ends with two extensions. PHP Code:
Array ( [0] => http://www.domain.com [1] => http:// [2] => www. [3] => domain [4] => com ) Wrong output with www.domain.com.uk Array ( [0] => http://www.domain.com.uk [1] => http:// [2] => www. [3] => domain.com [4] => uk ) The .com part should go with the other extension (uk) . |
How about parse_url instead? Will that do the trick?
|
Quote:
|
Well, what you could do.. is just use explode. Make sure the domain is formatted like: www.domain.com.uk or whatever (without slashes or beginning http://), and then just do this:
PHP Code:
|
Quote:
Thanks, though. |
That is a rather clean version.. also, if it works, why not use it if you can't find another way to do it?
|
I'd be tempted to use Andrew's anyway regardless. Regex isn't the fastest, as you'd expect, and if something can be achieved with increased performance, then I would be inclined to go for it.
|
php Code:
|
Mhmm,
PHP Code:
|
| All times are GMT. The time now is 01:24 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0