Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Exploding

  1. #1
    TrainReq
    Guest

    Exploding

    how would I go about going more/less this:

    Load everything from a specified page (such as www.site.com/userlist.html) , and then get everything that has something after userid= (NUMBER) .. for example.. if this is on the userlist.html :

    userid=111
    userid=222
    userid=333

    it will grab it as 111
    222 and 333 , and put it the things that it exploded from into an array like this.

    $random = array(
    '111',
    '222',
    '333'
    );


    so more/less explode everyhing after userid= under the page http://www.site.com/userlist.html , and then put it into an array like the one above.


    Hard to explain what I want to do, hope someone gets my question and can help me out.

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    well assuming the page only contains a list of userid= and nothing else you could
    str_replace("userid=", "", $text);
    then explode on newline characters to give you an array but if your page isnt like that then it wont work and without seeing what is in the page its hard to say. Theres probably some regexp matching you could do but without seeing the real page its hard to say

  • #3
    TrainReq
    Guest
    eh.. the HTML page more/less looks like this

    [html]
    TEXT HERE BLAH BLAH BLAH , THESE ARE USERS ONLINE <br>
    <a href=http://www.site.com/blah.php?userid=555> USER 1 </a> <a href="http:///www.site.com/blah.php?userid=222> USER 2 </a> [/html]

    etc..

    i just want to more/less go anywhere where it says userid=333 , it will extract the number after userid= , and place it into an array.

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    Definately will need regexp then.

    Something like this should do what you need
    PHP Code:
    preg_match_all("|userid=([\d]*)|"$text$matches,PREG_SET_ORDER);

    foreach(
    $matches as $match)
    {
      
    $users[]=$match[1];


  • #5
    TrainReq
    Guest
    Alright, what is the code that I can make it get the userids off a remote page.


  •  

    Posting Permissions

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