Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2005
    Posts
    194

    PHP Need to remove a . ?

    I am using a php script to check out the whois.

    I have a variable there called: $tld
    It is taking fro a file where I have defined like .com, .net etc...

    Now as search I need and its work fine but after result I need to pass it for an other step where dont need to come . in the first.

    Suth as com will come instead of .com

    can any one tell me how to remove the first dot in the tld?

    Thanks,
    Raza

  2. #2
    Join Date
    Jan 2005
    Location
    Baghdad, Iraq
    Posts
    172
    PHP Code:
    $without_dotsubstr($tld13); 
    Regards
    The Dream is the blueprint of success, the hope is the budget and hard working is the achievement

  3. #3
    Join Date
    Apr 2005
    Posts
    194
    Thanks Oras. Its work fine with .com but having probelm with .co.uk as result coming for .co.uk is "co." - uk is missing.

    any idea how to deal with it.

    if you clear me about 1,3 in the code may help me to fix the issue.


    Thanks,
    Raza

  4. #4
    substr -- Return part of a string
    Description
    string substr ( string string, int start [, int length] )

    substr() returns the portion of string specified by the start and length parameters.

    If start is non-negative, the returned string will start at the start'th position in string, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.
    RTFM http://www.php.net/substr

  5. #5
    But correct function is:
    PHP Code:
    $domain strstr($tld'.'); 

  6. #6
    Quote Originally Posted by realwebsolution
    But correct function is:
    PHP Code:
    $domain strstr($tld'.'); 
    That is not going to work with subdomains.
    :: Mountain Network Systems :: 323-933-9291
    eCommerce solutions since 1995
    http://www.webcart.net/

  7. #7
    Right... The best way is to have an array with allowed tld's and use it, but this is another story.

  8. #8
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    PHP Code:
    <?php
        $domain 
    'example.com';
        
    $domain explode('.',$domain);
        
    $domain array_reverse($domain);
        
        
    # com
        
    $tld $domain[0];
        
    # example
        
    $domain $domain[1];
    ?>
    That's what I would do. You can then do whatever you want with $tld and $domain. This won't work with '.co.uk' or '.com.au' or any domains like that, but this is enough for a simple WHOIS.

  9. #9
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    PHP Code:
    $string '.oogahboogah';
    $string2 '.co.uk';
    $string3 '.my.very.long.tld';

    echo 
    substr($string,1);
    echo 
    substr($string2,1);
    echo 
    substr($string3,1); 
    Its the first example from the substr() manual page. You really should read the manual first.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  10. #10
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342

    Arrow

    Quote Originally Posted by fyrestrtr
    PHP Code:
    $string '.oogahboogah';
    $string2 '.co.uk';
    $string3 '.my.very.long.tld';

    echo 
    substr($string,1);
    echo 
    substr($string2,1);
    echo 
    substr($string3,1); 
    Its the first example from the substr() manual page. You really should read the manual first.
    I was about to say: echo substr($string,1,strlen($string)); >>> but yours looks better

    Peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •