jakebur01 Posted April 6, 2009 Share Posted April 6, 2009 I have searched and not been able to figure how to return to a new line after 8 number of loops or tabs when writing to a text file. I would like to write 8 fields then tab to a new line. Something like: $i = 0; $tmp = $html->find('span[class=mqEmp], span[class=Black11]'); $cnt = count($tmp) - 1; foreach($tmp as $e) { if($i > 0 && $i < $cnt){ $outputstring=$e->plaintext . '\t'; fwrite($fp, $outputstring, strlen($outputstring)); // if eighth field, then start a new row something like: fwrite($fp, \n); } $i++; } Link to comment https://forums.phpfreaks.com/topic/152871-solved-returning-after-8-tabs/ Share on other sites More sharing options...
9three Posted April 6, 2009 Share Posted April 6, 2009 if $i == 8 break; //Whatever you want continue; Link to comment https://forums.phpfreaks.com/topic/152871-solved-returning-after-8-tabs/#findComment-802808 Share on other sites More sharing options...
jakebur01 Posted April 6, 2009 Author Share Posted April 6, 2009 Yea, but I need it to repeat after every eight rows. Link to comment https://forums.phpfreaks.com/topic/152871-solved-returning-after-8-tabs/#findComment-802815 Share on other sites More sharing options...
thepip3r Posted April 6, 2009 Share Posted April 6, 2009 if ($i % 8 == 0) { #insert tab, line-feed, whatever } Link to comment https://forums.phpfreaks.com/topic/152871-solved-returning-after-8-tabs/#findComment-802821 Share on other sites More sharing options...
jakebur01 Posted April 6, 2009 Author Share Posted April 6, 2009 Wow! That's exactly what I was looking for. Thanks a lot man. Link to comment https://forums.phpfreaks.com/topic/152871-solved-returning-after-8-tabs/#findComment-802825 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.