shuffle

Definition

1
Arr::shuffle(array $array): array
Copied!

Description

Shuffle array preserving keys and returning new shuffled array

Examples

1
$array = [
2
'a' => 1,
3
'b' => 2,
4
'c' => 3,
5
'd' => 4,
6
'e' => 5,
7
];
8
9
Arr::shuffle($array) ->
10
[
11
'e' => 5,
12
'a' => 1,
13
'c' => 3,
14
'b' => 2,
15
'd' => 4,
16
]
17
18
Arr::shuffle($array) ->
19
[
20
'a' => 1,
21
'e' => 5,
22
'b' => 2,
23
'd' => 4,
24
'c' => 3,
25
]
Copied!
Last modified 2yr ago
Copy link