...

View Full Version : Exploding



TrainReq
07-17-2007, 09:41 AM
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.

NancyJ
07-17-2007, 10:00 AM
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

TrainReq
07-17-2007, 11:09 AM
eh.. the HTML page more/less looks like this



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>

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.

NancyJ
07-17-2007, 11:40 AM
Definately will need regexp then.

Something like this should do what you need


preg_match_all("|userid=([\d]*)|", $text, $matches,PREG_SET_ORDER);

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

TrainReq
07-17-2007, 08:39 PM
Alright, what is the code that I can make it get the userids off a remote page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum