Hi, I'm having some trouble figuring out a piece of code for my website. I have very little knowledge about php, so it's difficult for me to figure out. Basically, I want to dynamically insert my domain name, minus the "www" and ".com". I already have a piece of code that gets the page name and dynamically inserts it. Here is the piece of code: <? function pageName() { $uri = strtolower(urldecode($_SERVER['REQUEST_URI'])); if(strpos($uri,"?")>0) $uri = substr($uri,0,strpos($uri,"?")); $uri = strrev(strtolower($uri)); $slash = strpos($uri,"/"); $uri = strrev(substr($uri,0,$slash)); $uri = str_replace('-',' ',$uri); $uri = str_replace('.html','',$uri); $uri = str_replace('.htm','',$uri); $uri = str_replace('.php','',$uri); $uri = ucwords($uri); return($uri); } print "".pageName().""; ?> From what I know, this code will grab the anything after the forward slash, and removes the appened .php, .html, .htm. I think that I would have to change this string: $uri = strrev(substr($uri,0,$slash)), but I don't know what I would change it to. Here is what I need done: Example URL (www*widgets*com) Function should remove: "widgets" from the URL and store it in a variable. Any help would be appreciated. Thanks
Don't understand well,.. do you want only THE NAME of that domain.. like www.something.com... and you want just SOMETHING in you variable? if so... what if there is domain like mail.yahoo.com should be in variable then MAIL... or YAHOO ?
Hi krampus, Sorry, about that. I know my explanation is a little vague, but I'll tell you what I'm going to use it for so you can get a better idea. I have about 5 domains that are part #'s for a particular high end product. I'm creating landing pages for those part numbers that will show their descriptions, features, specifications, etc... Now, instead of manually inputting the part number in it's designated space, every single time I decide to use it on the page, I would like to just pull that # from the domain itself, then insert it dynamically. So, I wouldn't need the "www" or ".com" part. Does this help?
ok. why don't you use ID number from the database for the # sign... or you dont use database for that?
Yeah, I'm not running a database on these. I know that can be an option, but I figure if I can just modify that code that I already have, then it will be quicker.
looks like this one had similar problem as you http://lists.evolt.org/archive/Week-of-Mon-20031201/152316.html