| 
 Posted by Geoff Berrow on 01/21/06 20:02 
Message-ID: <Tv6dnRECt6mD80_eRVn-rQ@comcast.com> from JackM contained 
the following: 
 
>Can anyone show me the error of my ways? It's probably something dumb  
>but I've worked on this for two days now trying all kinds of variations  
>and can't get it to work. Thanks for any help. 
<?php 
$file = "file.txt"; 
$cols=4; 
$pos=0; 
$result = file($file); 
$lines = count($result); 
$spaces=($lines%$cols>0)? 1 : 0; 
$rows=floor($lines/$cols)+$spaces; 
echo "<table border='2'>\n"; 
 
for($i=0;$i<$rows;$i++){ 
echo "<tr>\n"; 
	for($j=0;$j<$cols;$j++){ 
		if(isset($result[$pos])){ 
		echo "\t<td>".trim($result[$pos])."</td>\n"; 
		} 
		else{ 
		echo "\t<td> </td>\n"; 
		} 
	$pos++; 
	} 
echo "</tr>\n"; 
} 
echo "</table>"; 
?> 
 
--  
Geoff Berrow (put thecat out to email) 
It's only Usenet, no one dies. 
My opinions, not the committee's, mine. 
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
 
[Back to original message] 
 |