array_splice

array_splice

array_splice

is used to remove a portion of array and can be replaced with new value.

array array_splice ( array &input, int offset [, int length [, array replacement]] )

<?php

$arr = array(’one’,'two’,'three’,'four’);
array_splice($arr,3)
/// $arr will now contain array(’one’,'two’,'three’)

$arr = array(’one’,'two’,'three’,'four’);
array_splice($arr,1,-1)
/* $arr will now contain array(’one’,'four’)
which means remove the portion start from offset 1
and remove upto (final offsest -1)
*/

$arr = array(’one’,'two’,'three’,'four’);
array_splice($arr,1,3,”five”)
/* $arr will now contain array(’one’,'five’)
*/

?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.