Results 1 to 10 of 10

Thread: Using Split?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    16

    Using Split?

    Is it possible to use split in PHP? I want to know how to make it get some words from a website like in visual basic:-

    Code:
    mainstr = Inet1.OpenURL("http://www.google.co.uk/search?hl=en&q=vb6")
    text1.text = "Results " & split(split(mainstr, "Results")(1), (0.05 seconds) ")(0)
    I want to convert that into php, is it possible?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Using Split?


  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    16

    Re: Using Split?

    This is what I've done so far (trying to get my expire data on rapidshare)

    Code:
    <?php
    function ExpireDate($username, $password) {
    $page = @file_get_contents('https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi?login=' . $username . '&password=' . $password);
    $splitx = split("valid until ", $page);
    $splitx2 = split(" If " ,  $splitx[1]);
    $result = $splitx2[0];
    if ( $result == "" ) {
       return "Unknown Error!";
        }else{
       return $result;
       }
    }
    
    ?>
    But when I goto the page it asks me if I want to download the file (I do have a PHP enabled server)

    Is there anything wrong in the code?

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Using Split?

    Yes the split function is explode().

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    16

    Re: Using Split?

    I've changed the words split to explode but it is still asking me if I want to download the file.

  6. #6
    Hyperactive Member NPassero's Avatar
    Join Date
    May 2007
    Location
    NJ
    Posts
    272

    Re: Using Split?

    the explode function works like this:

    $sentance = "This is a sentance with a lot of words";
    $words = explode( " ", $sentance); // Splits it wherever there is a space

    result:
    $words[0] = This
    $words[1] = is
    $words[2] = a
    $words[3] = sentance ... etc

  7. #7
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345

    Re: Using Split?

    Quote Originally Posted by phpcoder
    But when I goto the page it asks me if I want to download the file (I do have a PHP enabled server)
    I would say there is something wrong with it. Unless you've tried another PHP file on the same server and had it work fine. Try setting the content type.

  8. #8
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Re: Using Split?

    just try to run a simple php file on the same server:
    Code:
    <?php
    echo "It is running fine...";
    ?>
    if it still ask you to download the file then something is wrong with the server... maybe apache is not running...

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    16

    Re: Using Split?

    All other PHP files work, is it possible to use explode to find some text on a website, grab it and show it on the page?

  10. #10
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Re: Using Split?

    For finding something I would save the website to a string and then use strstr() or preg_match() to find it.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

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