Jump to content

NEED Help with this two line code!!


veat23

Recommended Posts

 

Lets say my website is http://www.yahoo.com/

 

When someone types in http://www.yahoo.com/abcd.com

 

I want to extract "abcd" and "com"

 

When I used this code <!--#echo var="REQUEST_URI" -->

It produced "/abcd.com"

How do i get rid of the "/"? Or have "abcd" and "com" seperated.

 

-----------------------------

I wrote a script that will do a will whois command. so when someone types in http://www.yahoo.com/abcd.com

 

It will do a whois of abcd.com.

 

 

THanks For your help.

Link to comment
https://forums.phpfreaks.com/topic/37856-need-help-with-this-two-line-code/
Share on other sites

<form action="" method="post">
Test a URL: <br />
<input type="text" value="http://www.yahoo.com/abcd.com" name="url">
<input type="submit" value="Test">
</form>

<?php
$string = $_POST["url"];;
$pattern = '/[?http:\/\/]+[a-z]*?[.]+[a-z]*?[.]+[com|net|org]*\//';
$replacement = '';
$exde = preg_replace($pattern, $replacement, $string);

$str = $exde;
print_r(explode('.', $str, 2));

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.