Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Substract from a string

Posted on 2006-11-17
3
547 Views
Last Modified: 2008-02-01
I using $_SERVER['HTTP_REFERER'] to get the referals to my site.

And I get them as
http://www.dunemaul.org/forums/viewtopic.php?t=8118
http://www.fallenheroes-guild.com/index.php
http://www.gwi.dk/Forum/viewtopic.php?t=395

I would like to store them as
http://www.dunemaul.org
http://www.fallenheroes-guild.com
http://www.gwi.dk

But I need help to how substract this.
0
Comment
Question by:brightwood
3 Comments
 
LVL 13

Accepted Solution

by:
rhickmott earned 500 total points
ID: 17966998
http://uk.php.net/function.parse-url

$url      =         parse_url($_SERVER['HTTP_REFERER']);
$url      =         $url['scheme'] . "://" . $url[host];
0
 
LVL 15

Expert Comment

by:babuno5
ID: 17967008
try using the parse url function
http://in.php.net/manual/en/function.parse-url.php
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17967075
If it's a whole list or URL's you have to parse, you can use this:

<?php

$s = 'http://www.dunemaul.org/forums/viewtopic.php?t=8118
http://www.fallenheroes-guild.com/index.php
http://www.gwi.dk/Forum/viewtopic.php?t=395';

preg_match_all('/.*?\/\/[^\/]+/', $s, $matches);

print_r($matches);

?>
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cpanel file manager 8 39
Number of hours between date in DB and now 8 21
how to access a remote mysql database with xampp 3 23
Ajax and PHP 9 29
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question