Foreach and arrays

I had a mysql query, and I needed to store the data for later. So, I:

1.created an array

$array = array();

2. as I looped through the mysql data, I added that data to the array

$array[] = $mysqldata;

3. I then later used a foreach to loop through the array:

foreach($array  as $data) { //this code looped through $array, and each time it get's data from the array it assignes it to $data
echo $data;
}

Bonus: foreaching through two arrays:

foreach(array_combine($array, $array1)  as $data => $data1) {
echo $data;
echo $data1;
}

Extra Bonus: foreaching with three arrays:

foreach (array_map(NULL, $array1, $array2, $array3) as $x) {
  list($array1, $array2, $array3) = $x;
echo $array1;
echo $array2;
echo $array3;
}
Advertisements