Minwork Array
  • Minwork Array
  • Common methods
    • has
    • get → getNestedElement
    • set → setNestedElement
    • remove
    • clone
    • getKeysArray
  • Object oriented methods
    • General information
  • Traversing array
    • Finding
    • Iterating
  • Manipulating array
    • Mapping
    • Filtering
    • Grouping
    • Sorting
    • Computations
    • Flattening
  • Validating array
    • check
    • isEmpty
    • isNested
    • isArrayOfArrays
    • isAssoc
    • isUnique
    • isNumeric
    • hasKeys
  • Utility methods
    • pack
    • unpack
    • createMulti
    • forceArray
    • getDepth
    • random
    • shuffle
    • nth
    • getFirstKey
    • getLastKey
    • getFirstValue
    • getLastValue
Powered by GitBook
On this page

Was this helpful?

  1. Common methods

remove

Previousset → setNestedElementNextclone

Last updated 5 years ago

Was this helpful?

Definition

Arr::remove(array $array, $keys): array

Description

Remove element inside array at path specified by keys.

$keys argument is parsed using method

Examples

$array = [
    'foo' => [
        1,
        'test' => [
            'abc' => 2,
            'def'
        ],
        [
            'bar' => true
        ],
    ],
];

Arr::remove($array, 'foo') -> []
Arr::remove($array, '') -> $array
Arr::remove($array, []) -> $array

Arr::remove($array, 'foo.test.abc') ->
[
    'foo' => [
        1,
        'test' => [
            // Removed
            //'abc' => 2,
            'def'
        ],
        [
            'bar' => true
        ],
    ],
]

Arr::remove($array, 'foo.test') ->
[
    'foo' => [
        1,
        // Removed
        /*'test' => [
            'abc' => 2,
            'def'
        ],*/
        [
            'bar' => true
        ],
    ],
]

Arr::remove($array, ['foo', 1, 'bar']) ->
[
    'foo' => [
        1,
        'test' => [
            'abc' => 2,
            'def'
        ],
        [
            // Removed
            //'bar' => true
        ],
    ],
]
getKeysArray