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 6800113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:55:47+00:00 2026-05-26T18:55:47+00:00

So here is the main simplepie code I’m trying to use, and I don’t

  • 0

So here is the main simplepie code I’m trying to use, and I don’t really understand how to initialize the other feeds I have set up. Basically what I’m trying to do is place each of those $feeds into different divs so the first div displays all 3 feeds, and then one div for each after that.

<?php
// Include the SimplePie library
require_once('simplepie.inc');

// Because we're using multiple feeds, let's just set the headers here.
header('Content-type:text/html; charset=utf-8');

// These are the feeds we want to use
$feeds = array(
    'SITE ONE URL',
    'SITE TWO URL',
    'SITE THREE URL');

$feeds2 = array(
    'SITE ONE URL');

$feeds3 = array(
    'SITE TWO URL');

$feeds4 = array(
    'SITE THREE URL');


// This array will hold the items we'll be grabbing.
$first_items = array();

// Let's go through the array, feed by feed, and store the items we want.
foreach ($feeds as $url)
{
    // Use the long syntax
    $feed = new SimplePie();
    $feed->set_feed_url($url);
    $feed->init();

    // How many items per feed should we try to grab?
    $items_per_feed = 3;

    // As long as we're not trying to grab more items than the feed has, go through them one by one and add them to the array.
    for ($x = 0; $x < $feed->get_item_quantity($items_per_feed); $x++)
    {
        $first_items[] = $feed->get_item($x);
    }

    // We're done with this feed, so let's release some memory.
    unset($feed);
}

// We need to sort the items by date with a user-defined sorting function.  Since usort() won't accept "SimplePie::sort_items", we need to wrap it in a new function.
function sort_items($a, $b)
{
    return SimplePie::sort_items($a, $b);
}

// Now we can sort $first_items with our custom sorting function.
usort($first_items, "sort_items");


// Begin the (X)HTML page.
?>
  • 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-26T18:55:48+00:00Added an answer on May 26, 2026 at 6:55 pm

    I would like to help but need to understand better what you are trying to do. As per my understanding you want to populate a top div with ALL THE CONTENTS OF THE THREE FEEDS and, then, below, have a separate div with each of the feeds contents. Like:

    <div id='feeds'>
     feed1-content-1
     feed1-content-2
     feed1-content-3
     feed2-content-1
     feed2-content-2
     feed2-content-3
     feed3-content-1
     feed3-content-2
     feed3-content-3
    </div>
    <div id='feeds2'>
     feed1-content-1
     feed1-content-2
     feed1-content-3
    </div>
    <div id='feeds3'>
     feed2-content-1
     feed2-content-2
     feed2-content-3
    </div>
    <div id='feeds4'>
     feed3-content-1
     feed3-content-2
     feed3-content-3
    </div>
    

    If that is what you want, I would like to throw in my 2cents: why the redundancy? However, only the coder really knows what (s)he wants to achieve. My suggestion is simple: just append a paragraph into the divs:

    $('#feeds').append('<p>'+feed+'</p>');
    and the appropriate feed into the appropriate div in the same way.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my main page code: <form><iframe name=iframe_pic src=iframe.html></iframe></form> Here is my iframe.html: <script
here's the main code at first I thought is was the message box but
Here is my code : public static void main(String[] args) { // System.setProperty( //
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
Here is a sample code: public class TestIO{ public static void main(String[] str){ TestIO
I am trying to get a url structure like this. http://example.com/blog/1/title-name-goes-here My main urls
JAVA Code Here is some part of my code that I have written in
Okay, I just directly put my code here: main.cpp mysqlpp::Connection conn(false); int main() {
I have a very strange error in my Qt project. Here is the code,
What am I doing wrong here: class Helo { // main: generate some simple

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.