3v4l.org

run code in 300+ PHP versions simultaneously
<?php $file1 = 'orders1.txt'; $file1CounterPart = 'order1-items.txt'; $file2 = 'orders2.txt'; $file2CounterPart = 'order2-items.txt'; $files = [$file1, $file1CounterPart, $file2, $file2CounterPart]; var_dump($files); function passes(array $files) { $orders = array_filter($files, function ($file) { return preg_match('/^orders\d+\.txt$/', $file); }); $orderItems = array_filter($files, function ($file) { return preg_match('/^order\d+\.txt$/', $file); }); var_dump($orders); var_dump($orderItems); } // var_dump( // [ // [ // 'orders1.txt', // 'order1-items.txt' // ], // [ // 'orders2.txt', // 'order2-items.txt' // ] // ] // );

preferences:
55.78 ms | 402 KiB | 5 Q