How do I display what element in the order of the array that Is used?
<p>This questions seems like it already ought to be answered here, however I can't find it, probably due to lack of terminology. Hopefully someone else in the same situation could benfit from this.</p>

<p>I have an array $post_item.(se below) I print data from it for example</p>

<pre><code>$post_item-&gt;ID
</code></pre>

<p>Is there a way to get the which item in the order I am printing. In other words I would like to count the items.</p>

<p>If the item is the one with ID 9 I would like to return a 0. If it's the one with ID 12, I would like to return a 1 etc.</p>

<pre><code>stdClass Object
    (
        [ID] =&gt; 9
        [post_author] =&gt; 1
        [post_date] =&gt; 2012-05-18 12:01:49
        [post_date_gmt] =&gt; 2012-05-18 12:01:49
        [post_content] =&gt; 
        [post_title] =&gt; barnbildarkiv
        [post_excerpt] =&gt; 
        [post_status] =&gt; inherit
        [comment_status] =&gt; open
        [ping_status] =&gt; open
        [post_password] =&gt; 
        [post_name] =&gt; barnbildarkiv
        [to_ping] =&gt; 
        [pinged] =&gt; 
        [post_modified] =&gt; 2012-05-18 12:01:49
        [post_modified_gmt] =&gt; 2012-05-18 12:01:49
        [post_content_filtered] =&gt; 
        [post_parent] =&gt; 0
        [guid] =&gt; http://dev.nuagency.se/wp-content/uploads/2012/05/barnbildarkiv.jpg
        [menu_order] =&gt; 0
        [post_type] =&gt; attachment
        [post_mime_type] =&gt; image/jpeg
        [comment_count] =&gt; 0
        [filter] =&gt; raw
    )
    stdClass Object
    (
        [ID] =&gt; 12
        [post_author] =&gt; 1
        [post_date] =&gt; 2012-05-18 12:02:00
        [post_date_gmt] =&gt; 2012-05-18 12:02:00
        [post_content] =&gt; 
        [post_title] =&gt; animals_hm_giftcards
        [post_excerpt] =&gt; 
        [post_status] =&gt; inherit
        [comment_status] =&gt; open
        [ping_status] =&gt; open
        [post_password] =&gt; 
        [post_name] =&gt; animals_hm_giftcards
        [to_ping] =&gt; 
        [pinged] =&gt; 
        [post_modified] =&gt; 2012-05-18 12:02:00
        [post_modified_gmt] =&gt; 2012-05-18 12:02:00
        [post_content_filtered] =&gt; 
        [post_parent] =&gt; 0
        [guid] =&gt; http://dev.nuagency.se/wp-content/uploads/2012/05/animals_hm_giftcards.jpg
        [menu_order] =&gt; 0
        [post_type] =&gt; attachment
        [post_mime_type] =&gt; image/jpeg
        [comment_count] =&gt; 0
        [filter] =&gt; raw
    )
    stdClass Object
    (
        [ID] =&gt; 63
        [post_author] =&gt; 1
        [post_date] =&gt; 2012-05-21 09:27:41
        [post_date_gmt] =&gt; 2012-05-21 09:27:41
        [post_content] =&gt; 
        [post_title] =&gt; wren-2
        [post_excerpt] =&gt; 
        [post_status] =&gt; inherit
        [comment_status] =&gt; open
        [ping_status] =&gt; open
        [post_password] =&gt; 
        [post_name] =&gt; wren-2
        [to_ping] =&gt; 
        [pinged] =&gt; 
        [post_modified] =&gt; 2012-05-21 09:27:41
        [post_modified_gmt] =&gt; 2012-05-21 09:27:41
        [post_content_filtered] =&gt; 
        [post_parent] =&gt; 62
        [guid] =&gt; http://dev.nuagency.se/wp-content/uploads/2012/05/wren-2.gif
        [menu_order] =&gt; 0
        [post_type] =&gt; attachment
        [post_mime_type] =&gt; image/gif
        [comment_count] =&gt; 0
        [filter] =&gt; raw
    )
</code></pre>
