Welcome Guest, Not a member yet? Register   Sign In
Extract website name string
#1

[eluser]Animas[/eluser]
I want to extract "mysite" from http://www.mysite.com(main website url). How to do this?

Thanks.
#2

[eluser]Crimp[/eluser]
If you mean, extract the domain from any website, you use JavaScript and camelcase from there (althoug not exactly sure how you would define the words). The URL is found by document.URL and then you treat that string.
#3

[eluser]Animas[/eluser]
base_url()easily shows the url. But I am looking for a way which removes "http://" from beginning and ".com/" from end. I tried word_censor() which doesn't recognize "/", ":" etc. So anyone knows how to do it?
#4

[eluser]Référencement Google[/eluser]
If this doesn't have to be dynamic, you could just add in your config.php file something like:

Code:
$config['site_name'] = 'yourwebsitename';

// Then call it in your application like this:
$this->config->item('site_name');

Is that helping?
#5

[eluser]xwero[/eluser]
Code:
preg_replace('/http:\/\/(.+).com/','$1',base_url());
It could be made more flexible.
#6

[eluser]Animas[/eluser]
[quote author="xwero" date="1209133026"]
Code:
preg_replace('/http:\/\/(.+).com/','$1',base_url());
[/quote]

This is want I need. For http://localhost/app/ where "localhost/app" will be extracted I tried
Code:
preg_replace('/http:\/\/(.+)/','$1',base_url());
and it extracts "localhost/app/" (an extra "/" at end).

So my revised version is
Code:
preg_replace('/http:\/\/(.+)\//','$1',base_url());
(for local host) and
Code:
preg_replace('/http:\/\/(.+).com\//','$1',base_url());
for .com.

Thank you guys.




Theme © iAndrew 2016 - Forum software by © MyBB