3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ['type' => 'foo'], ]; function hasDependencyTypeLoop(array $dependencies, string $type): bool { foreach ($dependencies as ['type' => $currentType]) { if ($currentType === $type) { return true; } } return false; } function hasDependencyTypeArrayAny(array $dependencies, string $type): bool { return array_any($dependencies, fn() => $currentType === $type); } var_dump(hasDependencyTypeLoop($data, 'foo')); var_dump(hasDependencyTypeArrayAny($data, 'foo'));
Output for 8.4.1 - 8.4.17, 8.5.0 - 8.5.2
bool(true) Warning: Undefined variable $currentType in /in/a7int on line 18 bool(false)
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.27, 8.3.29 - 8.3.30
bool(true) Fatal error: Uncaught Error: Call to undefined function array_any() in /in/a7int:18 Stack trace: #0 /in/a7int(22): hasDependencyTypeArrayAny(Array, 'foo') #1 {main} thrown in /in/a7int on line 18
Process exited with code 255.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.

preferences:
67.96 ms | 409 KiB | 5 Q