3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); $array = ['A', 'AA', 'AAA']; $arrayWithKeys = ['A' => 1, 'AA' => 2, 'AAA' => 3]; echo "array_find examples" . PHP_EOL; var_dump(array_find($array, static fn(string $value): bool => strlen($value) > 2)); // returns AAA var_dump(array_find($array, static fn(string $value): bool => strlen($value) > 3)); // returns null var_dump(array_find($arrayWithKeys, static fn(int $value, string $key): bool => $value === strlen($key))); // returns 1 echo PHP_EOL . "array_find_key examples" . PHP_EOL; var_dump(array_find_key($array, static fn(string $value): bool => strlen($value) > 2)); // returns 2 var_dump(array_find_key($array, static fn(string $value): bool => strlen($value) > 3)); // returns null var_dump(array_find_key($arrayWithKeys, static fn(int $value, string $key): bool => $value === strlen($key))); // returns A echo PHP_EOL . "array_any examples" . PHP_EOL; var_dump(array_any($array, static fn(string $value): bool => strlen($value) > 2)); // returns true var_dump(array_any($arrayWithKeys, static fn(int $value, string $key): bool => $value === strlen($key))); // returns true echo PHP_EOL . "array_all examples" . PHP_EOL; var_dump(array_all($array, static fn(string $value): bool => strlen($value) < 4)); // returns true var_dump(array_all($arrayWithKeys, static fn(int $value, string $key): bool => $value === strlen($key))); // returns true

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.130.0000.00918.31
8.3.120.0070.01118.58
8.3.50.0110.00418.50
8.2.250.0140.00418.59
8.2.240.0060.00916.68
8.1.300.0140.00416.52

preferences:
25.51 ms | 403 KiB | 5 Q