remove

Definition

1
Arr::remove(array $array, $keys): array
Copied!

Description

Remove element inside array at path specified by keys.
$keys argument is parsed using getKeysArray method

Examples

1
$array = [
2
'foo' => [
3
1,
4
'test' => [
5
'abc' => 2,
6
'def'
7
],
8
[
9
'bar' => true
10
],
11
],
12
];
13
14
Arr::remove($array, 'foo') -> []
15
Arr::remove($array, '') -> $array
16
Arr::remove($array, []) -> $array
17
18
Arr::remove($array, 'foo.test.abc') ->
19
[
20
'foo' => [
21
1,
22
'test' => [
23
// Removed
24
//'abc' => 2,
25
'def'
26
],
27
[
28
'bar' => true
29
],
30
],
31
]
32
33
Arr::remove($array, 'foo.test') ->
34
[
35
'foo' => [
36
1,
37
// Removed
38
/*'test' => [
39
'abc' => 2,
40
'def'
41
],*/
42
[
43
'bar' => true
44
],
45
],
46
]
47
48
Arr::remove($array, ['foo', 1, 'bar']) ->
49
[
50
'foo' => [
51
1,
52
'test' => [
53
'abc' => 2,
54
'def'
55
],
56
[
57
// Removed
58
//'bar' => true
59
],
60
],
61
]
Copied!
Last modified 2yr ago
Copy link