3v4l.org

run code in 300+ PHP versions simultaneously
<?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_STRING)); sort($array, SORT_STRING); var_dump($array);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
array(9) { [0]=> string(3) "red" [1]=> int(78) [3]=> int(12) [5]=> bool(false) [8]=> int(0) [9]=> bool(true) [13]=> float(2.12) [15]=> int(8) [16]=> string(2) "-s" } array(18) { [0]=> bool(false) [1]=> NULL [2]=> bool(false) [3]=> NULL [4]=> string(2) "-s" [5]=> int(0) [6]=> int(0) [7]=> bool(true) [8]=> int(1) [9]=> int(12) [10]=> string(2) "12" [11]=> float(2.12) [12]=> string(4) "2.12" [13]=> int(78) [14]=> int(78) [15]=> int(8) [16]=> string(3) "red" [17]=> string(3) "red" }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array(9) { [0]=> string(3) "red" [1]=> int(78) [3]=> int(12) [5]=> bool(false) [8]=> int(0) [9]=> bool(true) [13]=> float(2.12) [15]=> int(8) [16]=> string(2) "-s" } array(18) { [0]=> bool(false) [1]=> NULL [2]=> bool(false) [3]=> NULL [4]=> string(2) "-s" [5]=> int(0) [6]=> int(0) [7]=> bool(true) [8]=> int(1) [9]=> int(12) [10]=> string(2) "12" [11]=> float(2.12) [12]=> string(4) "2.12" [13]=> int(78) [14]=> int(78) [15]=> int(8) [16]=> string(3) "red" [17]=> string(3) "red" }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
array(9) { [0]=> string(3) "red" [1]=> int(78) [3]=> int(12) [5]=> bool(false) [8]=> int(0) [9]=> bool(true) [13]=> float(2.12) [15]=> int(8) [16]=> string(2) "-s" } array(18) { [0]=> bool(false) [1]=> NULL [2]=> bool(false) [3]=> NULL [4]=> string(2) "-s" [5]=> int(0) [6]=> int(0) [7]=> bool(true) [8]=> int(1) [9]=> string(2) "12" [10]=> int(12) [11]=> float(2.12) [12]=> string(4) "2.12" [13]=> int(78) [14]=> int(78) [15]=> int(8) [16]=> string(3) "red" [17]=> string(3) "red" }

preferences:
162.11 ms | 403 KiB | 156 Q