@ 2024-11-13T08:44:52Z <?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
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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).
Version System time (s) User time (s) Memory (MiB) 8.4.2 0.016 0.003 21.34 8.4.1 0.006 0.003 19.48 8.3.15 0.015 0.003 17.13 8.3.14 0.007 0.007 16.52 8.3.13 0.000 0.009 18.31 8.3.12 0.007 0.011 18.58 8.3.5 0.011 0.004 18.50 8.2.26 0.009 0.006 16.87 8.2.25 0.014 0.004 18.59 8.2.24 0.006 0.009 16.68 8.1.31 0.012 0.006 16.77 8.1.30 0.014 0.004 16.52
preferences:dark mode live preview
39.31 ms | 403 KiB | 5 Q