Hi, I'm completely stuck at this, so I'd appreciate it if you could help.
What I'm trying to do is this: I get a series of ID's from a database, and use this line of code:
array(1 => $id[$i]-61, 2 => $id[$i]-60, 3 => $id[$i]-59, 4 =>
$id[$i]-1, 5 => $id[$i], 6 => $id[$i]+1, 6 => $id[$i]+59 etc.
to calculate a new series of ID's. All these ID's are then put into an array again and the array is printed.
This works nice if the database query retreives only one ID, but once it retreives more, I end up with several arrays ($arr). I've spend the past 2 hours seeking for a way to merge all those ID's, but without any luck.
So, my question is:
How do I combine the different arrays that my script produces?
$query = mysql_query("SELECT territory.ID FROM territory WHERE UID=2")
or error("Sorry, there's a problem with our database, please try again later.");
while($result = mysql_fetch_array($query)){
$i = $i+1;
$id[$i] = $result["ID"];
}
foreach($id as $id[$i]){
$arr[$i] = array(1 => $id[$i]-61, 2 => $id[$i]-60, 3 => $id[$i]-59, 4 =>
$id[$i]-1, 5 => $id[$i], 6 => $id[$i]+1, 6 => $id[$i]+59,
8 => $id[$i]+60, 9 => $id[$i]+61);
}
print_r($arr);