array_insert for PHP

published on March 24, 2014 in Tips and Tricksno comments
Similar to array_splice, this array_insert function allows to insert an object in an array – thing that unfortunately is not possible with array_splice that deals only with array parameters. This function offers an option for replacing the item correspondent to the offset. function array_insert($array, $offset, $object[, $replace=false]) $array is the array to be modified $offset is the position where we want to insert our object. It needs to be positive and within the limits given by the dimension of the array. If it is less than 0, the object will be inserted as the first element;... read more »
Tags: