Dr Ben Warne Posted October 16, 2006 Share Posted October 16, 2006 For this code below<html><head></head><body><table><tr><th>Headlines</th><th>Message of the Day</th></tr><tr><td width='50%'>Column One</td><td width='*'><?php $filename = 'text.txt'; $array_of_lines = file($filename); foreach($array_of_lines as $line) print $line;?></td></tr></table></body></html>I want to permit the first line of the text file to be loaded into a table header cell (<th>) and the remainder of the file into an associated table data (<td>) cell.I think i use an If statement, but havnt a clue what to do Link to comment https://forums.phpfreaks.com/topic/24078-a-%E2%80%98data-driven%E2%80%99-page/ Share on other sites More sharing options...
printf Posted October 16, 2006 Share Posted October 16, 2006 use first_element = array_shift ( $array_of_lines );lexample...[code]<? $filename = 'text.txt'; $array_of_lines = file ( $filename );?><table> <tr> <th><?=array_shift ( $array_of_lines );?></th> </tr> <tr> <?foreach ( $array_of_lines AS $item ):?> <td><?=$item;?></td> <?endforeach?> </tr></table>[/code]me! Link to comment https://forums.phpfreaks.com/topic/24078-a-%E2%80%98data-driven%E2%80%99-page/#findComment-109445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.