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. Utility methods

shuffle

Definition

Arr::shuffle(array $array): array

Description

Shuffle array preserving keys and returning new shuffled array

Examples

$array = [
    'a' => 1, 
    'b' => 2, 
    'c' => 3, 
    'd' => 4, 
    'e' => 5,
];

Arr::shuffle($array) -> 
[
    'e' => 5,
    'a' => 1, 
    'c' => 3, 
    'b' => 2, 
    'd' => 4, 
]

Arr::shuffle($array) -> 
[
    'a' => 1, 
    'e' => 5,
    'b' => 2, 
    'd' => 4, 
    'c' => 3, 
]
PreviousrandomNextnth

Last updated 5 years ago

Was this helpful?