数组如下 -
padding-left:15px;
我想在[3] =>之后在数组中添加新值'电子邮件'
我该怎么办?
答案 0 :(得分:1)
<?php
$array = array(
'1' => 'staff',
'2' => 'Name',
'3' => 'Email',
'4'=> 'surname',
'5' => 'registrationno',
);
array_splice($array, 3, 0, 'myvalue');
print_r($array);
答案 1 :(得分:0)
您可以使用array_splice();
$input = array ( [1] => staff [2] => Name [3] => Email [4] => surname [5] => registrationno );
array_splice($input, 3, 0, "myvalue");
//$input is now array ( [1] => staff [2] => Name [3] => Email [4] => myvalue [5] => surname [6] => registrationno );