I have one div which contain UL and LI. In this I want to generate dynamic Id of that LI. right now I given static id of this .

Now In this I want to generate my li's ID like given below. Now I'm bit confused how will I get this.

<li id= "nav-fragment-1">
<li id= "nav-fragment-2">
<li id= "nav-fragment-3">
<li id= "nav-fragment-4"> 


<div id="featured">
  <ul class="ui-tabs-nav">
<?php $i = 0; foreach($posts as $post): ?>
   <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1">
    <a href="<?php //echo $i++;) ?>"><span><?php echo $this->escape($post['title']) ?>
<?php if($leads): ?>
      <p><?php echo $this->maxText($post['content'], 50, '...', true) ?></p>
    <?php endif ?></span>
  <img class="post-image" src="<?php echo $this->postImage($post['image'], '50px', '50px') ?>" alt="" title="<?php echo $this->escape($post['title']) ?>"/></a>
 </li>
<?php endforeach ?>
</ul>
</div>

This should work:

<div id="featured">
  <ul class="ui-tabs-nav">
    <?php $i = 0; foreach($posts as $post): ?>
      <?php $i++; ?>
      <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php echo $i; ?>">
        <a href="#">
          <span>
            <?php echo $this->escape($post['title']) ?>
            <?php if($leads): ?>
              <p><?php echo $this->maxText($post['content'], 50, '...', true) ?></p>
            <?php endif ?>
          </span>
          <img class="post-image" src="<?php echo $this->postImage($post['image'], '50px', '50px') ?>" alt="" title="<?php echo $this->escape($post['title']) ?>"/>
        </a>
      </li>
    <?php endforeach ?>
  </ul>
</div>

Thanks for your replay pritaeas.
I solved that problem. I add into my code like this and it's working.

 <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php echo ++$i; ?>">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.