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'); 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. 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. 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); 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
Archived
This topic is now archived and is closed to further replies.