3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $timePeriods = array( 'weekly' => 1, 'fortnightly' => 2, 'fourweekly' => 4, 'bianually' => 26, 'anually' => 52 ); $pregResult = array(); $periods = array_keys($timePeriods); $recordName = 'ni_fortweekly_earning_limit'; $regex = '(' . implode('|', $periods) . ')'; $a = preg_match($regex, $recordName, $pregResult); var_dump($pregResult[0]);
based on QHEZZ
Output for 4.3.0 - 7.1.0
string(6) "weekly"