1

Hi,
I need to insert a new value in middle of array.

For ex,
$arrayvariable=arrray("a","b","d");
I need to insert C in between b and d.

Thank you in advance.

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by prem2
1

Hi,
I need to insert a new value in middle of array.

For ex,
$arrayvariable=arrray("a","b","d");
I need to insert C in between b and d.

Thank you in advance.

use array_splice for that. below is the code. try it.

<?
$arrayvariable=array("a","b","d");
array_splice($arrayvariable, 2, 0, "c");
print_r ($arrayvariable);


?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.