[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Substract from a string

Posted on 2006-11-17
3
Medium Priority
?
562 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.
Suggested Courses
Course of the Month19 days, 10 hours left to enroll

872 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