<?php
$array = ["red", "color" => "red", 78, 78, 12, "12", false, null, false, 0, true, 1, 0, null, 2.12, "2.12", 8, "-s"];
var_dump(array_unique($array, SORT_REGULAR));
sort($array, SORT_REGULAR);
var_dump($array);
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
- array(10) {
[0]=>
string(3) "red"
["color"]=>
string(3) "red"
[1]=>
int(78)
[3]=>
int(12)
[5]=>
bool(false)
[6]=>
NULL
[10]=>
int(1)
[13]=>
float(2.12)
[15]=>
int(8)
[16]=>
string(2) "-s"
}
array(18) {
[0]=>
bool(false)
[1]=>
NULL
[2]=>
bool(false)
[3]=>
string(2) "-s"
[4]=>
int(0)
[5]=>
int(0)
[6]=>
NULL
[7]=>
int(12)
[8]=>
string(2) "12"
[9]=>
int(78)
[10]=>
int(78)
[11]=>
string(3) "red"
[12]=>
bool(true)
[13]=>
int(1)
[14]=>
float(2.12)
[15]=>
string(4) "2.12"
[16]=>
int(8)
[17]=>
string(3) "red"
}
- Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
- array(11) {
[0]=>
string(3) "red"
["color"]=>
string(3) "red"
[1]=>
int(78)
[3]=>
int(12)
[5]=>
bool(false)
[6]=>
NULL
[7]=>
bool(false)
[10]=>
int(1)
[13]=>
float(2.12)
[15]=>
int(8)
[16]=>
string(2) "-s"
}
array(18) {
[0]=>
NULL
[1]=>
NULL
[2]=>
string(3) "red"
[3]=>
int(0)
[4]=>
bool(false)
[5]=>
string(3) "red"
[6]=>
int(0)
[7]=>
bool(false)
[8]=>
string(2) "12"
[9]=>
int(12)
[10]=>
bool(true)
[11]=>
string(2) "-s"
[12]=>
int(1)
[13]=>
float(2.12)
[14]=>
string(4) "2.12"
[15]=>
int(8)
[16]=>
int(78)
[17]=>
int(78)
}
preferences:
141.32 ms | 403 KiB | 152 Q