对于数组内部的循环[关闭]

The code below works, but I need to run a loop for the results. For example where it says $results0 I need it to say $results[$var].

for($i = 0; $i < (count($results0)); $i++) {
    $teams[$i] = array(
        $results0[$i],
        $results1[$i],
        $results2[$i],
        $results3[$i],
        $results4[$i],
    );
}

$teams1 = array_sort($teams, $sortVar, SORT_ASC); 

I realize you cannot do this but I need something that looks like this but actually works:

for($i = 0; $i < (count($results0)); $i++) {
    $teams[$i] = array(
        for($j = 0; $j < (count($teams)); $j++) {
            ${'results'.$j}[$i],
    );
        }
}

$teams1 = array_sort($teams, $sortVar, SORT_ASC);

Also now I need to be able to sort by category. Thanks in advance, I'm aware my current code may not be secure, I'm doing that after I'm finished.

You might simply use array_map():

$results1 = array(1, 2, 3);
$results2 = array('a', 'b', 'c');
$results3 = array('I', 'II', 'III');

$zipped = array_map(function($r1, $r2, $r3) {
    return array($r1, $r2, $r3);
}, $results1, $results2, $results3);

var_dump($zipped);

We unlikely are able to provide an answer to the question about sorting since we have no idea what is "category" in your code. It doesn't appear anywhere. But give usort() a try.