Solved

Substract from a string

Posted on 2006-11-17
3
544 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now