3v4l.org

run code in 300+ PHP versions simultaneously
<?php $objects = [ (object)['cats' => 2], (object)['dogs' => 2], (object)['fish' => 10], (object)['birds' => 1], ]; $needleField = 'cats'; $needleValue = 2; var_export( array_any( $objects, fn($obj) => property_exists($obj, $needleField) && $obj->$needleField === $needleValue ) );
Output for 8.4.1 - 8.4.14, 8.5.0
true
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.1.30 - 8.1.33, 8.2.10 - 8.2.29, 8.3.5 - 8.3.28
Fatal error: Uncaught Error: Call to undefined function array_any() in /in/eYOuI:14 Stack trace: #0 {main} thrown in /in/eYOuI on line 14
Process exited with code 255.

preferences:
59.67 ms | 409 KiB | 5 Q