/hphp/test/slow/ext_array/array_unique.php
PHP | 60 lines | 54 code | 6 blank | 0 comment | 0 complexity | 135be92981d559422a86ced5f09e255e MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?hh
- function a() {
- $input = darray[
- "a" => "green",
- 0 => "red",
- "b" => "green",
- 1 => "blue",
- 2 => "red"
- ];
- $result = array_unique($input);
- var_dump($result);
- }
- function b() {
- $input = varray[
- 4,
- "4",
- "3",
- 4,
- 3
- ];
- $result = array_unique($input);
- var_dump($result);
- }
- function c() {
- $input = darray[
- "a" => "A",
- "b" => "C",
- 0 => "1",
- 2 => "01",
- 1 => 1,
- "c" => "C"
- ];
- var_dump(array_unique($input, SORT_STRING));
- var_dump(array_unique($input, SORT_NUMERIC));
- var_dump(array_unique($input, SORT_REGULAR));
- }
- function d() {
- $input = darray[
- 1 => 1,
- 'a' => 'A',
- 'b' => 'C',
- 0 => '1',
- 2 => '01',
- 'c' => 'C'
- ];
- var_dump(array_unique($input, SORT_REGULAR));
- }
- <<__EntryPoint>>
- function main_array_unique() {
- a();
- b();
- c();
- d();
- }