3v4l.org

run code in 300+ PHP versions simultaneously
<?php $projPicsList = [ 'foobar_1.jpg', 'foobar_2.jpg', 'foobar_12.jpg', 'foobar_th1.jpg', 'foobar_th2.jpg', 'sdfaso234_33.jpg', 'foobar_th12.jpg', 'foobar_th32.jpg', 'fsdfas_th56.jpg', 'sdfiweflsdfasd24sdfsd_sdfse_th67.jpg', ]; /* $thumbs = []; foreach($projPicsList as $file) { if(preg_match('/.*_th\d+\.jpg$/' , $file)) { $thumbs[] = $file; } }*/ $thumbs = array_filter($projPicsList, function($item){ return preg_match('/.*_th\d+\.jpg$/' , $item); }); print_r($thumbs);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Array ( [3] => foobar_th1.jpg [4] => foobar_th2.jpg [6] => foobar_th12.jpg [7] => foobar_th32.jpg [8] => fsdfas_th56.jpg [9] => sdfiweflsdfasd24sdfsd_sdfse_th67.jpg )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Array ( [3] => foobar_th1.jpg [4] => foobar_th2.jpg [6] => foobar_th12.jpg [7] => foobar_th32.jpg [8] => fsdfas_th56.jpg [9] => sdfiweflsdfasd24sdfsd_sdfse_th67.jpg )

preferences:
189.18 ms | 402 KiB | 196 Q