title: How to get row index?
body: <p>I have a database table:</p>
  
  <pre><code>ID  name
  15  name1
  27  name2
  39  name3
  </code></pre>
  
  <p>I need to assign to those rows indexes, like: name1 should have index 0, name2 - index 1, name3 - index 2:</p>
  
  <pre><code>ID  name  index
  15  name1 0
  27  name2 1
  39  name3 2
  </code></pre>
  
  <p>I'm trying to do it with cycle:</p>
  
  <pre><code>$sub = $wpdb-&gt;get_results("SELECT t.* FROM $wpdb-&gt;terms AS t, $wpdb-&gt;term_taxonomy AS tt WHERE tt.parent = $termID AND tt.term_id = t.term_id ");           
      $i=-1;
      foreach ($sub as $key) {
      $i++;
      $number[$i]=$i;
  }
  </code></pre>
  
  <p>The result of this cycle is:</p>
  
  <pre><code>$number[0]=0;
  $number[1]=1;
  $number[2]=2;
  </code></pre>
  
  <p>Now, I have, for example a row, which <code>ID</code> is 27. How should I get a index of this row? (should be 1)</p>