ngng Posted August 1, 2008 Share Posted August 1, 2008 I'm trying to pull a webpage that gets updated, dump it into an array to read each line indvidually, then ideally split line X by the tabs (\t). $raw = file_get_contents('http://www.nwac.us/products/OSOCMT'); Quote Link to comment https://forums.phpfreaks.com/topic/117772-solved-dump-webpage-source-to-an-array-access-each-line-individually/ Share on other sites More sharing options...
obsidian Posted August 1, 2008 Share Posted August 1, 2008 Instead of file_get_contents(), use file()... It puts each line into an array position automatically. Quote Link to comment https://forums.phpfreaks.com/topic/117772-solved-dump-webpage-source-to-an-array-access-each-line-individually/#findComment-605748 Share on other sites More sharing options...
genericnumber1 Posted August 1, 2008 Share Posted August 1, 2008 file() dumps it into an array automatically, if you want it in array form, use that instead of file_get_contents(). If you want to split the lines by tabs you could always do something like... <?php $lines = file($myFile); for($i = 0; $i < count($lines); ++$i) { $lines[$i] = explode("\t", $lines[$i]); } ?> .. to make it into a multidimensional array. If you don't want it in that form you could just use explode on the individual lines you want. Quote Link to comment https://forums.phpfreaks.com/topic/117772-solved-dump-webpage-source-to-an-array-access-each-line-individually/#findComment-605750 Share on other sites More sharing options...
ngng Posted August 1, 2008 Author Share Posted August 1, 2008 Instead of file_get_contents(), use file()... It puts each line into an array position automatically. doh! would you do it like this? $raw = file('http://www.nwac.us/products/OSOCMT'); $data = split("\t", $raw[37]); echo print_r($data); Quote Link to comment https://forums.phpfreaks.com/topic/117772-solved-dump-webpage-source-to-an-array-access-each-line-individually/#findComment-605753 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.