Strip URL only display domain

I have a url,, and I would like to display only exampledomain onto my page. strip out 'http://members' and '.com'

For example's index page has something like

<img src="members/images/logo<?=$exampledomain; ?>.png" />

ok this worked:

<?php $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; $ArrayOfStrings = explode(".", $url); echo $ArrayOfStrings[1]; include("variables/" . $ArrayOfStrings[1] . "/"); ?>

-------------Problems Reply------------

You included an explode tag. I'm assuming you are looking for help using the explode function?

$url = "";

$ArrayOfStrings = explode(".", $url);

echo $ArrayOfStrings[1];

I annotated this code to make it readable. Do some research next time:


$url = "";
$url_parsed = parse_url($url);
$host = $url_parsed["host"];
$host_exploded = explode(".", $host);

echo $host_exploded[count($host_exploded) - 2];


Category:php Views:0 Time:2011-11-21
Tags: php url

Related post

  • PHP: How to catch text written in url after my domain name 2011-10-12

    Please see the sample link/ senario below. Default page on "" is index.php. There is no folder or file named "khaled". When the above URL is typed, i want index.php to be called and check the name "khaled" in d

  • How to remove parameters in URL and display it in address bar without causing redirect in Javascript? 2011-12-14

    I have found numerous answers on how to extract the URL without the parameters. How do you rewrite the URL in the address bar without causing the page to reload with the new URL? shortURL = top.location.href.substring(0, top.location.href.indexOf('?'

  • Check both valid URL and valid Domain Name 2012-04-20

    i am using the following function, this gives me the right output but ONLY it checks is URL pattern not correct Domain name... filter_var($url, FILTER_VALIDATE_URL) If i'll enter the correct URL it displays it is valid but if i'll enter the correct U

  • Custom url for my domain email 2014-01-27

    Hi, I want to make custom url for my domain email apps. I have emails in outlook web app. I want to access my email ids through and also I want to increase my email id accounts for Kindly guide me an

  • How to get list of URLs for a domain 2009-06-28

    I would like to generate a list of URLs for a domain but I would rather save bandwidth by not crawling the domain myself. So is there a way to use existing crawled data? One solution I thought of would be to do a Yahoo site search, which lets me down

  • Regex: Match URLs for specific domain EXCEPT when a certain querystring parameter has a certain value 2009-10-21

    In short, I need to match all URLs in a block of text that are for a certain domain and don't contain a specific querystring parameter and value (refer=twitter) I have the following regex to match all URLs for the domain. \b(https?://)?([a-z0-9-]+\.)

  • How to Route URL from one domain to another 2010-05-24

    I am an C# ASP.NET developer. I am trying to route URL from one domain to another using Godaddy IIS Virtual dedicated server or Dedicated server for ASP.NET. For example I have a website application for client_A in my server which is intended to be u

  • javascript access is denied on window resize of url from different domain 2011-02-06

    I have a custom function that will open a window to the center of the screen from a different url. On my current case I am opening a url outside my domain. This is my function. function wopen(url, name, w, h) { w += 32; h += 96; wleft = (screen.width

  • Downloads images from URL and display it in a GridView 2011-06-13

    I have a URL where some images are exists. I want to retrieve all the images from that URL and display these images in the GridView. Now when I click any of thumb preview like in grid view then it should enlarge or load to full screen. putting the sn

  • Structuring a URL to display all results for scraping data 2011-07-24

    I am a GIS student working on a project focused on mapping unstructured data, in which I wrote a php script to scrape the following page that displays search results for US GIS job postings, to export to xml, geocode and map.

  • Unsafe JavaScript attempt to access frame with URL "URL1" from frame with URL "URL2". Domains, protocols and ports must match. 2011-07-30

    Im getting this error: Unsafe JavaScript attempt to access frame with URL "URL1" from frame with URL "URL2". Domains, protocols and ports must match. What I try to do is to insert into my html page iframe (embed youtube video) but link is taken from

  • Full url with schema, domain and port 2011-11-11

    How do assemble (using Zend Routes) the full url with schema, domain and port, not just a root-based path? Sample use case: we need to specify full url in the emails sent to the clients. AFAIK there is no any built-in solution but what is a best prac

  • I'm looking for a Sharepoint Webpart that can query a list for an RSS feed URL, then display it 2011-11-23

    Basically what I have a List that will be maintained by the user that has a field that contains a link to an RSS feed. I tried using the OOTB RSS and it's great, but you have to specify the feed URL and I need that to be based on user selection. For

  • php: Ensure redirection URL is inside domain 2012-01-25

    Suppose I have a function that redirects the page to the given URL (code below). For security reasons, I want to modify it so that it redirects only to the URLs inside my domain. public static function redirect($num, $url) { header($http[$num]); head

  • Rewrite url to sub domain in NGINX 2012-02-13

    I currently have a image being outputted by server side PHP at a url like this: I'd like to have this image viewable at the url: Is this possible in the nginx conf? Note: I currently have my "i" subdomain

  • URL Rewrite Sub-domain and Directory Structure in ASP.NET 4.0 2012-03-14

    I am trying to rewrite/redirect a url in ASP.NET 4.0 Example: Requested URL: Rewritten/Redirected URL:

  • XmlHttpRequest cannot load ajax call url. Origin domain is not allowed by Access-Control-Allow-Origin 2013-06-01

    I have two ajax call back function in my web page. There is a problem as you can see in the title. Here is my codes: $.ajax({ type: "POST", url: "", data: "{categoryId:" + categoryId + "}", contentType: "application

  • Masking Domain URL with Sub domain URL 2009-11-06

    Hai i'm having a subdomain ( but this is referred to mydomain/folder . the thing is i want the mask URL links and the masked url should be displayed following with sub domain can any one help me out . mydomain/folder/path to abc.exampl

  • How do I use mod_rewrite to alter which file is fetched based on the URL's sub-domain? 2010-01-16

    So say I have a URL being requested: sub.domain/file.bin and I wanted this file to be fetched: domain/hosted/sub/file.bin How would I structure the rewrite directives? I've been working on this for days, and it just gives me a headache... The sub-dom

Copyright (C), All Rights Reserved.

processed in 0.278 (s). 11 q(s)