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['table_name'], $matches)) { var_dump($matches[1]); if ($maxCreatedAt > (int) $matches[1]) { $drops[] = $row['table_name']; } } } var_dump($drops);
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 Warning: Illegal string offset 'table_name' in /in/n4vuv on line 25 array(0) { }
Output for 5.0.0 - 5.3.29, hhvm-3.10.0 - 3.12.0
array(0) { }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/n4vuv on line 24
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/n4vuv on line 24
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/n4vuv on line 24
Process exited with code 255.