3v4l.org

run code in 300+ PHP versions simultaneously
<?php $first = [ 'A' => 'B', 'c' => 'd', 'E' => 'f', 'G' => 'I', 'k' => 'F', 'm' => 'n', 'o' => 'p', ]; $second = [ 'a' => 'b', 'A' => 'b', 'C' => 'd', 'c' => 'D', 'e' => 'F', 'G' => 'H', 'i' => 'B', 'J' => 'D', 'm' => 'N', 'M' => 'n', 'O' => 'r', ]; echo "array_diff()\n"; var_export(array_diff($first, $second)); // case-sensitive value echo "\n---\narray_diff_key()\n"; var_export(array_diff_key($first, $second)); // case-sensitive key echo "\n---\narray_diff_ukey()\n"; var_export(array_diff_ukey($first, $second, 'strcasecmp')); // case-insensitive key echo "\n---\narray_diff_assoc()\n"; var_export(array_diff_assoc($first, $second)); // case-sensitive key, case-sensitive value echo "\n---\narray_diff_uassoc()\n"; var_export(array_diff_uassoc($first, $second, 'strcasecmp')); // first-occurring, case-insensitive key, case-sensitive value echo "\n---\narray_udiff()\n"; var_export(array_udiff($first, $second, 'strcasecmp')); // case-insensitive, value-only echo "\n---\narray_udiff_assoc()\n"; var_export(array_udiff_assoc($first, $second, 'strcasecmp')); // case-sensitive key, case-insensitive value echo "\n---\narray_udiff_uassoc()\n"; var_export(array_udiff_uassoc($first, $second, 'strcasecmp', 'strcasecmp')); // case-insensitive key, case-insensitive value
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.26, 8.1.0 - 8.1.13
array_diff() array ( 'E' => 'f', 'G' => 'I', 'o' => 'p', ) --- array_diff_key() array ( 'E' => 'f', 'k' => 'F', 'o' => 'p', ) --- array_diff_ukey() array ( 'k' => 'F', ) --- array_diff_assoc() array ( 'A' => 'B', 'c' => 'd', 'E' => 'f', 'G' => 'I', 'k' => 'F', 'm' => 'n', 'o' => 'p', ) --- array_diff_uassoc() array ( 'A' => 'B', 'E' => 'f', 'G' => 'I', 'k' => 'F', 'm' => 'n', 'o' => 'p', ) --- array_udiff() array ( 'G' => 'I', 'o' => 'p', ) --- array_udiff_assoc() array ( 'E' => 'f', 'G' => 'I', 'k' => 'F', 'o' => 'p', ) --- array_udiff_uassoc() array ( 'G' => 'I', 'k' => 'F', 'o' => 'p', )

preferences:
46.14 ms | 411 KiB | 5 Q