baccarak Posted June 14, 2009 Share Posted June 14, 2009 this will take most a few secs I have a flat file Database which runs a text file >> Latest Special Offers|12TH-14TH JUNE 2009|per room, per night, Bed and Breakfast, minimum 2 night stay|79.00|CONTACT HOTEL DIRECT << and use <link href="css/data.css" rel="stylesheet" type="text/css" /> <?php $fp = fopen('data/offer.txt','r'); if (!$fp) {echo 'ERROR: Unable to open file.</body></html>'; exit;} while (!feof($fp)) { $line = fgets($fp, 500); //use 2048 if very long lines list ($offer, $title, $description, $price, $details) = split ('\|', $line); echo "<div class='offer'>$offer</div>"; echo "<div class='title'>$title</div>"; echo "<div class='desc'>$description</div>"; echo "<div class='price'>£$price</div>"; echo "<div class='details'>$details</div>"; $fp++; } fclose($fp); ?> to display the problem I have is that the text file adds a blank line after the last record and since I have to add a £ into code >> £$price this echo's after the last record is displayed. What to I have to add to omit showing the last line and the extra £ sign. I have got this far and tripped up on this, please help Quote Link to comment https://forums.phpfreaks.com/topic/162149-solved-php-newbie-help/ Share on other sites More sharing options...
.josh Posted June 14, 2009 Share Posted June 14, 2009 well if I'm reading the problem correctly, use trim. Quote Link to comment https://forums.phpfreaks.com/topic/162149-solved-php-newbie-help/#findComment-855669 Share on other sites More sharing options...
baccarak Posted June 14, 2009 Author Share Posted June 14, 2009 I have added list ($offer, $title, $description, $price, $details) = split ('\|', $line); trim($line, "\x0D\xa0\x09\x00"); but no joy Latest Special Offers 12TH-14TH JUNE 2009 per room, per night, Bed and Breakfast, minimum 2 night stay £79.00 CONTACT HOTEL DIRECT £ thanks for replying CV Quote Link to comment https://forums.phpfreaks.com/topic/162149-solved-php-newbie-help/#findComment-855673 Share on other sites More sharing options...
baccarak Posted June 15, 2009 Author Share Posted June 15, 2009 sorted myself with : if (!empty($line)){ Quote Link to comment https://forums.phpfreaks.com/topic/162149-solved-php-newbie-help/#findComment-856169 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.