このコードがあるとします
$test = array();
$test['zero'] = 'abc';
$test['two'] = 'ghi';
$test['three'] = 'jkl';
dump($test);
array_splice($test, 1, 0, 'def');
dump($test);
出力が得られます
Array
(
[zero] => abc
[two] => ghi
[three] => jkl
)
Array
(
[zero] => abc
[0] => def
[two] => ghi
[three] => jkl
)
とにかくキーを設定できるので、代わりにキーを設定0
できますone
か? これが必要な実際のコードでは、位置 (この例では 1) と require キー (この例では 1 つ) は動的になります。