title: How to get postgres array's current index & not an value of index
body: <pre><code>FOREACH v_name IN ARRAY name_list  
    
  LOOP
  
   IF v_name = name_list[1]
  
      &lt;perform some steps&gt; 
      
   END IF;
  
  END LOOP;
  </code></pre>
  <p>In my postgres function, I'm using the above expression in <code>if</code> condition, where <code>v_name</code> is an text variable and <code>name_list</code> is a <code>text[]</code> (array text variable).
  with <code>name_list[1]</code>, It gives value of 1st indexed array, But I want to change this expression, and Verify it for the current index of array and not a value of array.
  So if current index is 1 then perform some statements.</p>
  <p>So my question is to how to get what is current index of array in postgresql?</p>