Jump to content

[SOLVED] Displaying content - \n echoing blank information...


TheLoveableMonty

Recommended Posts

Alright, simple query.

 

http://www.tenthousandbillboards.com/inf-bin/med/index.php

 

As you can see under the Spain heading, there's a blank entry. The script has been programmed so that there is little to no chance of a line break slipping through so the page will display normally. That one managed to slip in though, so as a precaution I'd like to know the following.

 

          foreach ($infoSort as $infoDraft){
              $infoLines   = explode("#~#", $infoDraft);
              $title       = $infoLines[0];
              $link        = $infoLines[1];
              $location    = "desc/".$infoLines[2].".dat";

              if(file_exists($location)) {
                  $description = file_get_contents($location);
              }

                  if ($infoDraft != "\n") {
                      echo "      <FONT FACE=\"trebuchet ms\" COLOR=\"#FFFFFF\" SIZE=\"2\">";
                      echo "      <BR><FONT FACE=\"trebuchet ms\" COLOR=\"#F3B809\" SIZE=\"2\"><B>$title</B></FONT> - ";
                      echo "      <A HREF=\"".$link."\">$link</A>\n";
                      if ($_COOKIE["u"] == $configUser && $_COOKIE["p"] == $configPass) {
                          echo "<BR><A HREF=\"index.php?option=editEntry&filename=".$infoLines[3]."\">Edit Entry</A>";
                          echo " - <A HREF=\"index.php?option=deleteEntry&filename=".$infoLines[3]."\">Delete Entry</A>";
                      }
                      echo "      </FONT>";

                  }
          }

 

How could I edit the above piece of code to not display blank lines from a data file? You can see my feeble attempt at attempting to not print lines from the $infoDraft variable. It doesn't work.

I got it.

 

I trimmed and checked the $title variable as it was the first instant of the split array.

 

I seem to have a habit of spending hours on a problem, posting here and correcting it not too long after.

 

Cheers.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.