Forum Moderators: coopster

Message Too Old, No Replies

How can I merge two arrays?

From an RSS source using the DOM

         

lonestar23

4:47 pm on May 12, 2009 (gmt 0)

10+ Year Member



I am trying to merge two different RSS sources with the same structure into a single list concurrently. I have two foreach statements but would like to combine them. Problem I can not turn a DOM Method into an array... Thanks in Advance.

###### CODE BELOW Using DOM METHOD #####


<?php
foreach($rssResults1 as $value){
echo('<div><a href="' . $value->childNodes->item($thing1)-> nodeValue . '">'); //Url
echo($value->childNodes->item($thing2)->nodeValue . '</a></div>'); //Title
}

foreach($rssResults2 as $value){
echo('<div><a href="' . $value->childNodes->item($thing11)->nodeValue . '">'); //Url
echo($value->childNodes->item($thing22)->nodeValue . '</a></div>'); //Title
}
?>

abidshahzad4u

6:42 pm on May 14, 2009 (gmt 0)

10+ Year Member



Use php array_merge() function.

Pico_Train

6:27 pm on May 16, 2009 (gmt 0)

10+ Year Member



$array1 = array();
$array2 = array();

$count = count($array1);

$i=$count;
foreach($array2 as $a)
{
$array1[$i] = $a;
$i++;
}

That's decent if array_merge isn't useful.

lonestar23

9:43 pm on May 16, 2009 (gmt 0)

10+ Year Member



I found out that DOM Elements can not be converted into arrays. I could not get array_merge to work. Perhaps "Pico_Train" your solution will work.