You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== array_remove ==
[[../objects/ms.lang.CastException|ms.lang.CastException]]
[[../objects/ms.lang.PluginInternalException|ms.lang.PluginInternalException]] |- ! scope="row" | Since | 3.3.0 |- ! scope="row" | Restricted |
Copy Code
The output would be:
Copy Code
The output would be:
Removes an index from an array. If the array is a normal array, all values' indices are shifted left one. If the array is associative, the index is simply removed. If the index exists, the value removed is returned. If the index doesn't exist, the array remains unchanged, however it'll throw a RangeException for normal arrays (returns null for associative arrays).
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| array_remove
|-
! scope="row" | Returns
| mixed
|-
! scope="row" | Usages
| array, index
|-
! scope="row" | Throws
| [[../objects/ms.lang.RangeException|ms.lang.RangeException]][[../objects/ms.lang.CastException|ms.lang.CastException]]
[[../objects/ms.lang.PluginInternalException|ms.lang.PluginInternalException]] |- ! scope="row" | Since | 3.3.0 |- ! scope="row" | Restricted |
No
|-
! scope="row" | Optimizations
| None
|}
=== Usages ===
array_remove(array, index)=== Examples === ====Example 1==== Basic usage Given the following code:
assign(@array, array(1, 2, 3))
msg(array_remove(@array, 2))
msg(@array)

1 {{function|assign}}(@array, {{function|array}}(1, 2, 3))
2 {{function|msg}}({{function|array_remove}}(@array, 2))
3 {{function|msg}}(@array)
3 {1, 2}====Example 2==== With associative array Given the following code:
assign(@array, array(one: 'a', two: 'b', three: 'c'))
msg(array_remove(@array, 'two'))
msg(@array)

1 {{function|assign}}(@array, {{function|array}}(one: 'a', two: 'b', three: 'c'))
2 {{function|msg}}({{function|array_remove}}(@array, 'two'))
3 {{function|msg}}(@array)
b {one: a, three: c}
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)