array_splice, split an array into 2 arrays. The returned arrays is the 2nd argument actually and the used array e.g $input here contains the 1st argument of array, e.g
<?php
$input = array("red", "green", "blue", "yellow");
print_r(array_splice($input, 3)); print_r($input); ?>
if you want to replace any array value do simple like that,
first search the array index you want to replace
<?php $index = array_search('green', $input);?>
and then use it as according to the definition
<?php
array_splice($input, $index, 1, array('mygreeen')); ?>
so here green is replaced by mygreen.
here 1 in array_splice above represent the number of items to be replaced. so here start at index '1' and replaced only one item which is 'green'