Hi there I have an key => value array. Key is numeric index and value is associative array. I want to add new element at a particular position and wants to move the existing one ahead. My array looks like
Array
(
[0] => Array
(
[States ] => States
[Call Count] => Call Count
[Leads] => Leads
)
[1] => Array
(
[States] => AK
[Call Count] => 0
[Leads] =>
)
[2] => Array
(
[States] => AL
[Call Count] => 0
[Leads] =>
)
[3] => Array
(
[States] => AR
[Call Count] => 0
[Leads] =>
)
)
Now I want to insert one index like 2=>array('States'=>'ABC','Call Count' =>5, 'Leads'=>2)
and wants index 2 to become 3 and 3 to become 4..... When I use
array_slice($outboundSummaryData, 0, 2, true) +
array('States ' => 'States', 'Call Count' => 'Call Count', 'Leads' => 'Leads') +
array_slice($outboundSummaryData, 2, count($outboundSummaryData) - 2, true);
It overrides my 2 index.
When I use
array_splice($outboundSummaryData, 2, 0, array('States ' => 'States', 'Call Count' => 'Call Count', 'Leads' => 'Leads'));
It insert my new array elements as main indexes of the array.
Any Help?