3v4l.org

run code in 300+ PHP versions simultaneously
<?php $stock = ["7", "5", "3"]; $request = ["3", "6", "3"]; echo "Are there any items with insufficient stock: "; var_export( array_any( $stock, fn($v, $i) => $v < $request[$i] ) ); echo "\n---\nDo all items have sufficient stock: "; var_export( array_all( $stock, fn($v, $i) => $v >= $request[$i] ) ); echo "\n---\nWhich stock item value is insufficient: "; // more helpful if $v was a row from a 2d array var_export( array_find( $stock, fn($v, $i) => $v < $request[$i] ) ); echo "\n---\nWhich stock indexes have an insufficient amount: "; var_export( array_find_key( $stock, fn($v, $i) => $v < $request[$i] ) );

preferences:
39.6 ms | 404 KiB | 5 Q