我有一个来自后期操作的数组
$country = $_POST['country']; //The number of countries differ according to the user selection
$c = count($country);
输出:`
Array ( [0] => England,69,93 [1] => Australia,79,84 [2] => Greece,89,73 [3] => Germany,59,73 )`
我将不得不将其分解为一个多维数组,例如:
> Array ( [0] => Array ( [0] => England [1] => 69 [2] => 93)
> [1] => Array ( [0] => Australia [1] => 79 [2] => 84)
> [2] => Array ( [0] => Greece [1] => 89 [2] => 73)
> [3] => Array ( [0] => Germany [1] => 59 [2] => 73))
我如何在 PHP 中执行此操作
我试过
$r = array();
foreach($country as &$r){
$r = explode(",", $r);
//for($i = 0; $i < count($country); $i++){
//for($j = 0; $j < count($r); $j++){
//$array[$i][$j] = $r;
//}
//}
}
echo '<br>';
print_r($r);
for 循环也不起作用,因此将其注释掉,但如果需要,将其作为一个选项。
print 函数现在只打印数组中的 1 个。不完全确定我做错了什么。任何帮助表示赞赏。谢谢