11-11-2008, 19:17
|
מנהל
|
|
חבר מתאריך: 26.07.08
הודעות: 6,473
|
|
הנה דוגמא אחת:
קוד PHP:
$cells = array();
$cells[] = 'Text1';
$cells[] = 'Text2';
$cells[] = 'Text3';
$cells[] = 'Text4';
$cells[] = 'Text5';
$cells[] = 'Text6';
$cells[] = 'Text7';
echo '<table>',
output_table($cells, 3),
'</table>';
function output_table($cells, $cells_per_row=1 /* Number of cells in each row */ )
{
$table = array_chunk($cells, $cells_per_row);
array_walk($table, 'implode_table');
}
function implode_table($cells, $id)
{
echo '<tr><td>',implode('</td><td>',$cells),'</td></tr>';
}
כאשר יש לך האפשרות לקבוע את אלמנט ה-table מחוץ לפונקציה הבונה את התאים והשורות, זה נותן לך עוד קצת דינאמיות (לקבוע name או id או style או class וכן הלאה)...
|