$array[1] = array("Name1"=> array("2"=>"1460","3"=>"1868","4"=>"2158","5"=>"2537","6"=>"2915","8"=>"3673"));
$array[2] = array("Prod2"=> array("3"=>"3079","4"=>"3625","5"=>"4172","6"=>"4718","8"=>"5811"));
$cnt = 0;
for ($x = 0; $x < 100; $x++) {
$product = $array[$x]; // dynamic all product`s - $name
foreach ($product as $good =>$massiv) {
$name = key($product); // prod name
$proklkadok = array_keys($massiv); // prod prokladok
foreach ($massiv as $inner_key =>$price) {
echo "<tr><td>". $name. "</td>";
$pr_val = array_keys($massiv);
echo "<td>".$pr_val[0]. "</td>";
echo "<td>".$price."</td></tr>\r\n"; // product price
}
}
}
如何在表td單元格中打印$pr_val
唯一? 這段代碼是錯誤的,壞表打印輸出:如何獲得不同的密鑰php數組表
Name1 2 1138 or wrong output too ... Name1 2,3,4,5,6,8 1138
Name1 2 1868 or wrong output too ... Name1 2,3,4,5,6,8 1868
Name1 2 2158 or wrong output too ... Name1 2,3,4,5,6,8 2158
Prod2 3 3079 or wrong output too ... Prod2 2,3,4,5,6,8 3079
Prod2 3 3625 or wrong output too ... Prod2 2,3,4,5,6,8 3625
Prod2 3 4718 or wrong output too ... Prod2 2,3,4,5,6,8 4718
Prod2 3 5811 or wrong output too ... Prod2 2,3,4,5,6,8 5811
正確的輸出必須在HTML表
Name1 2 1138
Name1 3 1868
Name1 4 2158
Name1 5 2537
Name1 6 2915
Name1 8 3673
Prod2 3 3079
Prod2 4 3079
Prod2 5 3625
Prod2 6 4718
Prod2 8 5811
請幫助我,我不能指望在輸出不同的計數陣列鍵表輸出
爲了使高品質的答案,你應該說明什麼問題是與原來的代碼,你改變來解決它。不要只是拋棄新的代碼而沒有解釋。 – Barmar
eoe非常感謝!但不是全部,稍後見到我親愛的frined! – Alexey