---
title: "array:put()"
description: "Returns a new array with the member at a given position replaced by a new value."
date: 2026-04-18T00:00:00Z
version: "3.0"
versionLabel: "XSLT 3.0"
category: "array function"
syntax: "array:put(array, position, value)"
tags: ["xslt", "reference", "xpath", "xslt3"]
---
## Description
`array:put()` produces a new array identical to the input except that the member at the specified 1-based position is replaced with the new value. Arrays are immutable in XDM; the original array is not modified. Out-of-range positions raise `err:FOAY0001`.
## Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `array` | array(*) | Yes | The source array. |
| `position` | xs:integer | Yes | The 1-based position of the member to replace. |
| `value` | item()* | Yes | The new value for that position. |
## Return value
`array(*)` — a new array with the member at `position` replaced by `value`.
## Examples
### Replacing a member in an array
**Stylesheet:**
```xml
```
**Output:**
```xml
- a
- B
- c
- d
```
### Updating JSON-like array data
**Input XML:**
```xml
```
**Stylesheet:**
```xml
```
**Output:**
```xml
- original-1
- updated-value
- original-3
```
## Notes
- Array positions are 1-based. Position `0` or greater than `array:size()` raises `err:FOAY0001`.
- The new value can be any XDM value, including a sequence (which becomes a single multi-item member).
- Arrays are immutable; the result is always a new array.
## See also
- [array:get()](../xpath-array-get)
- [array:append()](../xpath-array-append)
- [array:remove()](../xpath-array-remove)
- [array:insert-before()](../xpath-array-insert-before)
- [xsl:array](../xsl-array)