Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3607786
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:25:12+00:00 2026-05-18T21:25:12+00:00

I am working with SimplePie and I cannot figure out how to output the

  • 0

I am working with SimplePie and I cannot figure out how to output the count, or the key values for the loop.

Shouldn’t this

<?php foreach ($feed->get_items() as $item): ?>
        <?php
                $i = key($item);
                echo $i;
        ?>
<?php endforeach; ?>

, or this

<?php foreach ($feed->get_items() as $item): ?>
        <?php
                $i = count($item);
                echo $i;
        ?>
<?php endforeach; ?>

be outputting a unique number for each?

uniqid() Doesn’t work in this case, because I am running the loop twice on the page and trying to match up one list of elements with another based on ID.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:25:12+00:00Added an answer on May 18, 2026 at 9:25 pm

    A single argument used with as is interpreted as a variable in which to store the value, not the key. If you want the key, you need to use => in a manner like the following:

    foreach ($feed->get_items() as $key => $item):
        echo $key;
    endforeach
    

    As a sidenote, you’re using key() and count() on an item in the array, rather than the array as a whole, which is invalid. As far as I’m aware, there’s no guarantee that key() will work as you expect even if applied to the whole array. It’s meant for loops where you control the iteration, as with next.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a web application and want to use SimplePie for parsing
I am working on an RSS reader using SimplePie. I want to pull in
Working with Json, how can I NSlog only the title in this code: NSDictionary
Working through more book examples- this one is a partial poker program- This segment
Working on this question, I found an inconsistent behavior. Why reference binding behave different
Working on a web based buying and selling application with PHP MySQL where users
Currently i am working on simplepie rss reader in which i have to fetch
Working on this EF tutorial , I've difficult to understand the meaning of the
Working on THIS Page: newsite.702wedding.com/live/ Can't find where to remove the arrows at the
Working through this for fun: http://www.diku.dk/hjemmesider/ansatte/torbenm/Basics/ Example calculation of nullable and first uses a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.