BRADERY Posted January 23, 2011 Share Posted January 23, 2011 So I have a text file "name.txt" in the text file I have ids and auth keys set up like this 1234564 abcdfhu 3123900 sdkoao etc How could I make it to where the ids are $ids and the auth keys are $auth_keys? I've tried using foreach() but I cant get it Link to comment https://forums.phpfreaks.com/topic/225391-need-some-help-with-reading-file-and-assigning-variables/ Share on other sites More sharing options...
trq Posted January 23, 2011 Share Posted January 23, 2011 <?php $lines = file('name.txt'); foreach ($lines as $line) { $arr = explode(' ', $line); $ids = $arr[0]; $auth_keys = $arr[1]; echo "$ids = $auth_keys"; } Link to comment https://forums.phpfreaks.com/topic/225391-need-some-help-with-reading-file-and-assigning-variables/#findComment-1163931 Share on other sites More sharing options...
BRADERY Posted January 23, 2011 Author Share Posted January 23, 2011 man I write PHP like a fuckin 3rd grader, but it works <?php $login = "fblogin.txt"; $target = ""; $key = file($login); foreach($key as $keys){ $info = explode(' ', $keys); $id = $info[0]; $auth = $info[1]; echo "$info[0] || $info[1]"; sleep(1);} echo "Sleeping 10 seconds".sleep(10); Link to comment https://forums.phpfreaks.com/topic/225391-need-some-help-with-reading-file-and-assigning-variables/#findComment-1163936 Share on other sites More sharing options...
trq Posted January 23, 2011 Share Posted January 23, 2011 man I write PHP like a fuckin 3rd grader, but it works It might work, but maintaining a large application written like that would be a chore. Link to comment https://forums.phpfreaks.com/topic/225391-need-some-help-with-reading-file-and-assigning-variables/#findComment-1163940 Share on other sites More sharing options...
BRADERY Posted January 23, 2011 Author Share Posted January 23, 2011 Yeah Ill clean it up Link to comment https://forums.phpfreaks.com/topic/225391-need-some-help-with-reading-file-and-assigning-variables/#findComment-1163968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.