Question : loop an array in an array and insert into db

Hello,

I have 2 arrays.
Array1 = ("news1-id","news2-id","news3-id");
Array2 = ("site1-id","site2-id");

I need to insert these into a db as such:  
news1-id, site1-id
news1-id, site2-id
news2-id, site1-id
news2-id, site2-id
news3-id, site1-id
news3-id, site2-id

So that each of the news items are assigned to a site.
I need to loop through two arrays and I need ideas please.

Thanks.

Answer : loop an array in an array and insert into db

The attached gets just mimics what you are asking... should get you started
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
<?
$Array1 = array("news1-id","news2-id","news3-id");
$Array2 = array("site1-id","site2-id");

foreach($Array1 as $key => $value){
   foreach($Array2 as $key2 => $value2){    
       echo "$value,$value2<br>";
   }
}
?>
Random Solutions  
 
programming4us programming4us