jednak pojawia sie pewien problem, ktory z pewnoscia zdazyliscie juz zauwazyc. na gorze zawsze wyskakuja puste komorki. suma pustych komorek z komorkami wypelnionymi danymi jest sobie rowna.
jak nalezy zmodyfikowac skrypt, aby nie pojawialy sie puste komorki i zostaly tylko te, ktore maja w srodku jakies dane?
z gory dziekuje za pomoc.
ponizej zamiszczam kod skryptu.
Kod
<? // Begin php processing;
echo "<body bgcolor=#FFFFFF>";
///////////////////////////
// Function for reading a single dimension (column) array into a multiple dimension array
// Copyright 2000 by J.G. Smirniotopoulos
// Made available for non-commercial public use, provided this copyright attribution is intact
// Requires:
// $cols = number of columns for output array
// $buffers = single column array with cell values separated by commas ( , )
//
// NOTE: You can clearly organize your data into columns this way;
// The first row (0) can optionally be used for column headings;
// Each entry (line) must end with a comma ( , );
//
// SAMPLE Array using comma [,] as separator;
//
$buffers=file("data.txt");
$buffers = implode($buffers, "");
;// end string;
$buff = explode (",", $buffers);
////////////////////////////
// Create Multidimensional Array
//
// requires array $buff;
// requires number of columns for output table $cols;
$cols=0;// define number of columns here;
function make_table($cols,$buff){
$rows=((count($buff))/$cols); // calculate number of rows;
echo "<table width=100% valign=top align=center border=0 bgcolor=#FFFFFF >";
$item=0;
while ($item < (count($buff))):
for ($row=0; $row < $rows; $row++){
if (($row%2)==0){echo "<tr bgcolor=#C6C6C6>";}else{echo "<tr bgcolor=#FFFFFF>";};
if ($row>0){
echo "<td>". ($row)." </td>";
}else{
echo "<td><b>#</b></td>";
}
for ($col=0; $col < $cols; $col++){
$myarray[$row][$col]=$buff[$item];
echo "<td>".$myarray[$row][$col];// optional display;
// if ((($col+1)%$cols)!=0) { echo " - is associated with - ";};// optional display;
echo "</td>";
$item++;// loop items;
}// loop columns;
echo "<br>";
echo "</tr>";
}// loop rows;
endwhile;
echo "</table>";
}// end function make_table;
make_table(6,$buff);// number of columns, input array;
//////////////////////////
// End php processing;
?>
echo "<body bgcolor=#FFFFFF>";
///////////////////////////
// Function for reading a single dimension (column) array into a multiple dimension array
// Copyright 2000 by J.G. Smirniotopoulos
// Made available for non-commercial public use, provided this copyright attribution is intact
// Requires:
// $cols = number of columns for output array
// $buffers = single column array with cell values separated by commas ( , )
//
// NOTE: You can clearly organize your data into columns this way;
// The first row (0) can optionally be used for column headings;
// Each entry (line) must end with a comma ( , );
//
// SAMPLE Array using comma [,] as separator;
//
$buffers=file("data.txt");
$buffers = implode($buffers, "");
;// end string;
$buff = explode (",", $buffers);
////////////////////////////
// Create Multidimensional Array
//
// requires array $buff;
// requires number of columns for output table $cols;
$cols=0;// define number of columns here;
function make_table($cols,$buff){
$rows=((count($buff))/$cols); // calculate number of rows;
echo "<table width=100% valign=top align=center border=0 bgcolor=#FFFFFF >";
$item=0;
while ($item < (count($buff))):
for ($row=0; $row < $rows; $row++){
if (($row%2)==0){echo "<tr bgcolor=#C6C6C6>";}else{echo "<tr bgcolor=#FFFFFF>";};
if ($row>0){
echo "<td>". ($row)." </td>";
}else{
echo "<td><b>#</b></td>";
}
for ($col=0; $col < $cols; $col++){
$myarray[$row][$col]=$buff[$item];
echo "<td>".$myarray[$row][$col];// optional display;
// if ((($col+1)%$cols)!=0) { echo " - is associated with - ";};// optional display;
echo "</td>";
$item++;// loop items;
}// loop columns;
echo "<br>";
echo "</tr>";
}// loop rows;
endwhile;
echo "</table>";
}// end function make_table;
make_table(6,$buff);// number of columns, input array;
//////////////////////////
// End php processing;
?>