3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $minAge = 86400; // 24h $rows = array( 'import_1364893316_foobar', 'import_1364893306_foobar', 'import_1364893216_foobar', 'import_1364892316_foobar', 'import_1364883316_foobar', 'import_1364793316_foobar', 'import_1363893316_foobar', 'import_1354893316_foobar', 'import_1354893416', 'import_1354893316', ); $drops = array(); $maxCreatedAt = true === $minAge ? time() - $minAge : time() + 1; foreach ($rows as $row) { if (preg_match('/_([0-9]+)[0-9]{6}[_a-zA-Z]*$/', $row, $matches)) { var_dump($matches[1]); if ($maxCreatedAt > (int) $matches[1]) { $drops[] = $row; } } } var_dump($drops);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(4) "1364" string(4) "1364" string(4) "1364" string(4) "1364" string(4) "1364" string(4) "1364" string(4) "1363" string(4) "1354" string(4) "1354" string(4) "1354" array(10) { [0]=> string(24) "import_1364893316_foobar" [1]=> string(24) "import_1364893306_foobar" [2]=> string(24) "import_1364893216_foobar" [3]=> string(24) "import_1364892316_foobar" [4]=> string(24) "import_1364883316_foobar" [5]=> string(24) "import_1364793316_foobar" [6]=> string(24) "import_1363893316_foobar" [7]=> string(24) "import_1354893316_foobar" [8]=> string(17) "import_1354893416" [9]=> string(17) "import_1354893316" }