victorianrider Posted October 21, 2010 Share Posted October 21, 2010 Ok so what I have is a list of 32,000 IDs in a separate file called 32kIDs.txt and it has a list of roughly 32,000 user IDs for facebook which look like 100000233850312;1521225383;100000282767638;1252335882;1804268242 They're all separated by a semi-colon. What I need this script to do is echo each and every ID on screen, echoing each ID on a new line. I have been using the explode function but having trouble with it since I'm very new to PHP and don't have much experience yet. Here is my current code: <?PHP $iFile = "32kIDs.txt"; $login = file($iFile, FILE_SKIP_EMPTY_LINES); if(!is_file($iFile)) echo "The 32k add list couldn't be found...".sleep(999999); foreach($login as $line_num => $line) { $login = explode(" ", htmlspecialchars(str_replace(";"," ",$line))); echo $login[0]."\n"; } sleep(20); ?> So I bet there are going to be things in there that I don't even need and thing's I'm missing, if anyone can help it would be much appreciated. And I'd like to keep the code short, I could just put in: echo $login[0]."\n"; echo $login[1]."\n"; echo $login[2]."\n"; echo $login[3]."\n"; all the way up to echo $login[32246]."\n"; but yeah I don't like the thought of a 32k+ line script. Anyways... Quote Link to comment Share on other sites More sharing options...
litebearer Posted October 21, 2010 Share Posted October 21, 2010 Presuming there are only numbers and semi-colons... $string = file_get_contents($filename); $myarray = explode(";"$string); $count = count($myarray); $i=0; while($i<$count) { echo $myarray[$i] . "<br>"; $i ++; } Quote Link to comment Share on other sites More sharing options...
victorianrider Posted October 21, 2010 Author Share Posted October 21, 2010 Presuming there are only numbers and semi-colons... $string = file_get_contents($filename); $myarray = explode(";"$string); $count = count($myarray); $i=0; while($i<$count) { echo $myarray[$i] . "<br>"; $i ++; } Thankyou so much, worked a treat Cheers Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted October 21, 2010 Share Posted October 21, 2010 Aside from the parse error in the explode line litebearers code is a way to do it, however I prefer foreach(): $string = file_get_contents($filename); $logins = explode(";", $string); foreach($logins as $login) { echo $login . "<br>"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.