我有這樣創建多維數組,
$assoc = ['name','lastname','pesel'];
$inputs = ['a', 'a', 'a', 'a', 'b', 'b', 'b', 'b',];
$counter = 0;
$internalcounter = 0;
$zero = 0;
$content = array();
while ($counter < sizeof($inputs))
{
if($internalcounter == sizeof($assoc))
{
$counter++;
$internalcounter = 0;
}
else
{
array_push($content, $inputs[$counter]);
$counter++;
$internalcounter++;
}
}
var_dump($content);
代碼它創建陣列誰看起來
`array(6) { [0] => string(1) "a" [1] => string(1) "a" [2] => string(1) "a" [3] => string(1) "b" [4] => string(1) "b" [5] => string(1) "b" }`
但我想創建多維數組
Array ([0] => Array ([0] => "a" [1] => "a" [2] => "a" ) [1] => Array ([0] => "b" [1] => "b" [2] => "b") )
如何在$ content中添加下一個數組?
我必須無恥地承認,我不知道(或逃脫我的心),你可以定義這樣的數組。 – Kermit 2013-03-09 18:48:52
你有什麼確切的要求?你想要每個子數組包含3個值嗎?或者只有同一個字母的值? – 2013-03-09 18:49:41
@AarolamaBluenk它出現在PHP 5.4 – Hast 2013-03-09 18:50:53