If I know that I'm only looping two times in a while loop, how do I switch array values after the first loop?
This is my array, $myarr:
Array ( // echo out array values from first loop
[id1] => values_one
[id2] => values_two
)
Array ( // echo out array values from second loop
[id2] => values_two
[id1] => values_one
)
$arr = array_values($myarr);
while($row = $query->fetch(PDO::FETCH_ASSOC))
{
// ... more code
//echo's out array values
echo $arr[0]; //first loop should be values_one, second loop should be values_two
echo $arr[1]; //first loop should be values_two, second loop should be values_one
}
Thank you