Remove a portion of the array and replace it with something else.

Paramètres

array $input: The input array.

int $offset: If offset is positive then the start of removed portion is at that offset from the beginning of the input array. If offset is negative then it starts that far from the end of the input array.

int $length: If length is omitted, removes everything from offset to the end of the array. If length is specified and is positive, then that many elements will be removed. If length is specified and is negative then the end of the removed portion will be that many elements from the end of the array. Tip: to remove everything from offset to the end of the array when replacement is also specified, use count($input) for length.

mixed $replacement: If replacement array is specified, then the removed elements are replaced with elements from this array. If offset and length are such that nothing is removed, then the elements from the replacement array are inserted in the place specified by the offset. Note that keys in replacement array are preserved. If replacement is just one element it is not necessary to put array() around it, unless the element is an array itself, an object or NULL.

Voir aussi

http://php.net/array-splice#111204

1 call to advagg_array_splice_assoc()
advagg_get_js dans ./advagg.module
Returns a themed presentation of all JavaScript code for the current page.

Fichier

./advagg.module, line 3070

Code

function advagg_array_splice_assoc(array &$input, $offset, $length, $replacement) {
    $replacement = (array) $replacement;
    $key_indices = array_flip(array_keys($input));
    if (isset($input[$offset]) && is_string($offset)) {
        $offset = $key_indices[$offset];
    }
    if (isset($input[$length]) && is_string($length)) {
        $length = $key_indices[$length] - $offset;
    }
    $input = array_slice($input, 0, $offset, TRUE) + $replacement + array_slice($input, $offset + $length, NULL, TRUE);
}