2

I get the contents of rss feeds, but for my bad luck they have different structure. With the help of the community I got over this problem though.

My question is how can I combine $entries1 and $entries2 into $entries3 ? What I will achieve is to handle and sort all feeds with different structure.

Thank you.

FIRST CODE

<?php
$feeds1 = array('','','');
$entries1 = array();
foreach ($feeds1 as $feed1) {
    $xml = simplexml_load_file($feed1);
    $entries1 = array_merge($entries1, $xml->xpath('/rss/channel//item'));
} 
echo "<pre>"; print_r($entries1); echo"</pre>";
?>
1
  • Sorry, missed some details in your post when I answered... Whats the result of the above code when the arrays are not empty? :) Commented Jun 9, 2011 at 22:57

1 Answer 1

3

To answer your question, I believe you would simply use array_merge() ...

$entries3 = array_merge($entries1, $entries2);

or even

$entries6 = array_merge($entries1, $entries2, $entries3, $entries4, $entries5);

or am I just not understanding this question?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.