title: How to add a span tag if the UL list is first child and last child? PHP Condition if else
body: <p>I'm working on WordPress custom fields and I need to write PHP if-else conditions in a loop whether it is the first child or last child of the ul list. but I don't know how to apply, kindly please help me to solve it</p>
  
  <p>Here is my code below</p>
  
  <pre><code>&lt;?php if( have_rows('chart') ): ?&gt;
  &lt;ul class="list-unstyled"&gt;
  &lt;?php while( have_rows('chart') ): the_row();
  $sr_no = get_sub_field('sr_no');
  $list_content = get_sub_field('list_content');
  ?&gt;
  &lt;li&gt;&lt;div&gt;&lt;span class="w-num"&gt;&lt;?php echo $sr_no; ?&gt;&lt;/span&gt;&lt;?php echo $list_content; ?&gt;&lt;/div&gt;&lt;span class="chart-divider"&gt;&lt;span class="chart-divider-r"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;?php endwhile; ?&gt;
  &lt;/ul&gt;
  &lt;?php endif; ?&gt;
  </code></pre>