Jump to content


A ‘Data Driven’ Page

  • Please log in to reply
1 reply to this topic

#1 Dr Ben Warne

Dr Ben Warne
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 16 October 2006 - 10:44 AM

For this code below

<th>Headlines</th><th>Message of the Day</th>
<td width='50%'>Column One</td>
<td width='*'>
    $filename = 'text.txt';
    $array_of_lines  = file($filename);
    foreach($array_of_lines as $line)
    print $line;

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

#2 printf

  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 16 October 2006 - 11:24 AM

use first_element = array_shift ( $array_of_lines );l


    $filename = 'text.txt';
    $array_of_lines = file ( $filename );
		<th><?=array_shift ( $array_of_lines );?></th>
	<?foreach ( $array_of_lines AS $item ):?>


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users