title: How to check for first/last row of an array in Coldfusion?
body: <p>I've built a basic navigation menu in which the sub menus are controlled by arrays, however (only for style purposes at the minute) I want to be able to check when the array is outputting the first/last line so that I can remove the bottom border on the <code>&lt;li&gt;</code> giving a neat and tidy sub menu. If anyone would be able to help, it would be greatly appreciated.</p>
  
  <p>How to do it:</p>
  
  <pre><code>&lt;cfset thisArray = [
      {name="Page", href="page.cfm"},
      {name="Page2", href="page2.cfm"}
  ]&gt;
  &lt;cfif arrayLen(thisArray) neq 0&gt;
      &lt;cfset start = 1&gt;
      &lt;ul&gt;
          &lt;cfloop array="#thisArray#" index="array"&gt;
              &lt;cfif start eq arrayLen(thisArray)&gt;
                  &lt;li class="navItem" style="border-bottom: 0;"&gt;&lt;a href="#array['href']#"&gt;#array['name']#&lt;/a&gt;&lt;/li&gt;
              &lt;cfelse&gt;
                  &lt;li class="navItem"&gt;&lt;a href="#array['href']#"&gt;#array['name']#&lt;/a&gt;&lt;/li&gt;
              &lt;/cfif&gt;
              &lt;cfset start = start + 1&gt;
          &lt;/cfloop&gt;
      &lt;/ul&gt;
  &lt;/cfif&gt;
  </code></pre>
  
  <p>That is basically how I want it to work, check for the last row, or the current row matching last row, this usually works fine for queries however I can tell it doesn't for arrays as I haved tried this method and it didn't work for me. Thanks.</p>
  
  <p><strong>EDIT:</strong>
  I have literally just found a solution, using a custom variable called <code>start</code> and setting it to one, each time the loop is performed it increments by 1 and a check is performed against the arrays length, if <code>start</code> is equal to it, then it simply removes the bottom border now.</p>