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. Link to comment https://forums.phpfreaks.com/topic/37856-need-help-with-this-two-line-code/ 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. Link to comment https://forums.phpfreaks.com/topic/37856-need-help-with-this-two-line-code/#findComment-181207 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)); ?> Link to comment https://forums.phpfreaks.com/topic/37856-need-help-with-this-two-line-code/#findComment-181247 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. Link to comment https://forums.phpfreaks.com/topic/37856-need-help-with-this-two-line-code/#findComment-181251 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.