(Victor Nicollet yaptığı açıklamada bahseder gibi) mevcut veri yapısını düzeltmek için böyle bir şey gerekir:
$users = array(); // Create an empty array for the users? (Maybe testsets is a better name?)
$testset = array(); // Create an empty array for the first testset
// Add the test details to the testset (array_push adds an item (an array containing the results in this case) to the end of the array)
array_push($testset, array("testcase"=>"101", "buildid"=>"b12", "resultsid" => "4587879"));
array_push($testset, array("testcase"=>"102", "buildid"=>"b13", "resultsid" => "4546464"));
// etc
// Add the testset array to the users array with a named key
$users['MAIN_TEST_SET'] = $testset;
// Repeat for the other testsets
$testset = array(); // Create an empty array for the second testset
// etc
Tabii ki sizin veri yapısını oluşturmaya çok daha fazla yöntem vardır, ama bu bir Aklıma en net görünüyor / görünüyor.
Yukarıda açıklanan veri yapısını kullanarak bir HTML tablosu oluşturmak için böyle bir şey kullanın.
echo "<table>\n";
foreach($users as $tsetname => $tset)
{
echo '<tr><td colspan="3">'.$tsetname.'</td></tr>\n';
foreach($tset as $test)
echo "<tr><td>".$test['testcase']."</td><td>".$test['buildid']."</td><td>".$test['resultsid']."</td></tr>\n";
}
echo "</table>\n";
Test setleri ve test seti testleri üzerinde ikinci bir dolaşır üzerinde ilk foreach dolaşır.