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

  • SEARCH
  • Home
  • 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 6353495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:25:24+00:00 2026-05-24T22:25:24+00:00

how to add an offset and limit to my PHP rss parser that returns

  • 0

how to add an offset and limit to my PHP rss parser that returns the result as an object ?, here is what i have at the moment. it doesn’t have any offset nor limit, how to approach this ?

    class Rss
{
     /*
     *@access public
     *@params url,int ''=default,int ''=default
     *@usage input url,offset and limit,
     *@returns content based onf the offset/limit input
     */
    public function getFeed($url,$offset='',$limit=''){
        $object = array();
        $rss = simplexml_load_file($url);
      foreach($rss->channel->item as $item){
          $object[] = $item->title;
          $object[] = $item->description;
          $object[] = $item->link;
      }
     return $object;
   }
}
  • 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-24T22:25:25+00:00Added an answer on May 24, 2026 at 10:25 pm

    Simpliest way

    $limit = 10; $offset = 5; 
    $i=0; $taken=0;
    foreach($rss->channel->item as $item){
        if ($i>=$offset && $taken<$limit){
            ++$taken;
            $object[] = $item->title;
            $object[] = $item->description;
            $object[] = $item->link;
        }
        //little optimization here
        if ($taken == $limit)
            break;
        ++$i;
    }
    

    Of course you can store $limit and $offset as object properties, or get them elsewhere.

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

Sidebar

Related Questions

I have a fixed-width page that I want to add a simple border to
I add this class to library/My/Validate/PasswordConfirmation.php <?php require_once 'Zend/Validate/Abstract.php'; class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract {
Is it possible to make a PHP application think that the server datetime is
I am building an application that must add an overlay view once a scrollview
I have this code to add new elements to a multidimension array: $this->shopcart[] =
So I have my query as so... $records = ORM::factory('category'); Add a WHERE clause
We have a sample app that loads 10 records each from the db and
I have tried offset in simpledb but it's not working as it was working
I have a problem with reading an rss feed in my site. When i
I need to export big amount of data from database. Here is classes that

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.