PHP foreach循环外循环

I'm trying to wrap my head around PHP and variable scope. Take a look at the following:

<?php  foreach ($data as $tip) { ?>              
  <tr>
    <td><?php echo $tip['id']; ?></td>
    <td><?php echo $tip['title']; ?></td>                  
    <td class="delete"><a href="#deleteModal" class="modal"><i class="icon-cross"></a></i></td> 
  </tr>                                                
<?php } ?>

This just runs a foreach loop that pulls some information out of the database and displays it in a table. The last table cell has an icon in it for deleting that article. What I'm trying to do is have a modal popup that asks for conformation to delete that specific article but I cannot tie the tip id with the delete button because the modal window sits outside the loop. How can I go about accessing the individual id?

Do this :

<?php  foreach ($data as $tip) { ?>              
  <tr>
    <td><?php echo $tip['id']; ?></td>
    <td><?php echo $tip['title']; ?></td>                  
    <td class="delete" onclick="deleteArticle(<?php echo $tip['id'] ?>)">
         <a href="#deleteModal" class="modal">
           <i class="icon-cross"></i>
         </a>
    </td> 
  </tr>                                                
<?php } ?>

<script>
   function deleteArticle(id){
     // now you can do what ever you want to do with this id
   }
</script>

There is a built it javascript function called "confirm".

If you're using JQuery (And I assume you are) try this:

$('.delete').click(function(){
  var check = confirm("Are you sure you want to delete this article?");
  if(check)
  {
    // you code here
  }
  else return false;
});