3v4l.org

run code in 300+ PHP versions simultaneously
<?php function arraykey(int|string $arg) : int|string { return $arg; } var_dump([ arraykey("foo") => "foo", arraykey(42) => 42, ]);
Output for 8.1.3
array(2) { ["foo"]=> string(3) "foo" [42]=> int(42) }

preferences:
20.64 ms | 408 KiB | 5 Q