Results 1 to 3 of 3

Thread: <resloved>string out host name

  1. #1

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Resolved <resloved>string out host name

    hi, i would like to string out the host name so that if the full host name was something like "dan.dws05.ath.cx" then it would return the first bit which is "dan".
    thanks, dandono
    Last edited by dandono; May 14th, 2005 at 07:09 AM.
    If there is only one perfect person in the universe, does that make them imperfect?

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: string out host name

    You can combine the strpos() function with the substr() function to extract it. strpos returns the first occurrence of a particular character and substr extracts a portion of a string.
    PHP Code:
    $str 'dan.dws05.ath.cx';

    $first_part substr($str0strpos($str'.') - 1); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Hyperactive Member dandono's Avatar
    Join Date
    Aug 2004
    Location
    Cornwall, UK
    Posts
    485

    Re: string out host name

    i had to take the -1 part out because you made it to take away the last letter for some reason and i changed it to string out $_SERVER['HTTP_HOST']. other than that it worked fine.
    thanks, dandono
    If there is only one perfect person in the universe, does that make them imperfect?

Posting Permissions

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



Click Here to Expand Forum to Full Width