problem with elseif
Posted: Fri Jan 20, 2006 4:09 pm
I have some script that lists the contents of text files based on whether there is a specific letter "a, b, c..." within the text file. I am trying to include a elseif statement to tell the user of the page that there are no files if the letter does not comply...Here's the code:
So if the letter is "k" it will list the file...The first IF statement works perfectly, the elseif isn't catching the exceptions...
What am I doing wrong???
Thnx.
Code: Select all
//go through the array of files and list each
foreach ( $listings_array as $val ) {
$listings_file = file("admin/listings/listings/$val");
//create name variable (name = first line of listing_file array [k, c, e, w])
$name = $listings_file[0];
//if the first character of line 1 = the first character of the member's name list their posts
if ($name[0] == "k"){
$listMembers = array_shift($listings_file);
$listAddress = array_shift($listings_file);
$listDescription = implode('<BR>',$listings_file);
echo '<font class="LISTINGS" align="left"><b>'.$listAddress.'</font></b>';
echo '<font class="BODY_TEXT" align="left"><BR>'.$listDescription.'</font><br><HR class="HORIZ_RULE_BTM" width="95%" align="left">';
break;
}
elseif ($name[0] != "k"){
echo '<font class="BODY_TEXT_BOLD" align="left"><b>There are no available properties in this area.</font></b>';
break;
}
}What am I doing wrong???
Thnx.