I'm sure there is a really easy answer to this question, but I'm pretty new and don't not sure what I need.
I need to read a text file and have every other line formatted the same. I have a css class set up for lets say odd lines and one set up for the even lines.
Each Title is on one line and each position is on another. All the titles have the same class and all the positions have the same class. I'm just not sure how to set this up in some repeating form so if I have more than 5 titles and positions it will automatically read and format them.Code:// retrieve first and second lines (position and description) $title = array_shift($raw); $position = array_shift($raw); $title2 = array_shift($raw); $position2 = array_shift($raw); $title3 = array_shift($raw); $position3 = array_shift($raw); $title4 = array_shift($raw); $position4 = array_shift($raw); $title5 = array_shift($raw); $position5 = array_shift($raw); // start building output page // add page header $output = // add page content $output .= "<h1 class='title'>$title</h1>"; $output .= "<p class='position'>$position</p>"; $output .= "<h1 class='title'>$title2</h1>"; $output .= "<p class='position'>$position2</p>"; $output .= "<h1 class='title'>$title3</h1>"; $output .= "<p class='position'>$position3</p>"; $output .= "<h1 class='title'>$title4</h1>"; $output .= "<p class='position'>$position4</p>"; $output .= "<h1 class='title'>$title5</h1>"; $output .= "<p class='position'>$position5</p>"; // display in browser echo $output;



Reply With Quote
Bookmarks