eval.in

Paste #184830

PHP — PHP 5.5.14, pasted 1 year ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

$a = [ 10 ,  0x30 ];
$b = ['10', '0x30'];

echo json_encode(array_intersect($a, $b));
echo "\n\n";

$a = ["foo" => 1, 2];
$b = [1, "bar" => 2];

var_dump(array_intersect($a, $b));
echo "\n\n";

$a = [[1], [2]];
$b = [[3], [4]];

echo json_encode(array_intersect($a, $b));
echo "\n\n";

$a = [null];
$b = [''];

echo json_encode(array_intersect($a, $b));
echo "\n\n";

Program Output

[10]

array(2) {
  ["foo"]=>
  int(1)
  [0]=>
  int(2)
}


[[1],[2]]

[null]

OK (0.012 sec real, 0.014 sec wall, 14 MB, 58 syscalls)

Fork