veat23 Posted February 10, 2007 Share Posted February 10, 2007 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. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 10, 2007 Share Posted February 10, 2007 substr(), explode(), strpos() are functions which you could use. Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted February 10, 2007 Share Posted February 10, 2007 <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)); ?> Quote Link to comment Share on other sites More sharing options...
13th_Star Posted February 10, 2007 Share Posted February 10, 2007 //$income = /abcd.com $income = str_replace("/", "", $income); $income = explode(".", $imcome); //$income[0] now = abcd // and $income[1] now = com simple way. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.