3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //$regex = '/(?P<function_name>.*?)\s*\((?P<parameters>.*?)\)\s*/i'; $regex = '/(?P<function_name>.+)\s*\((?P<parameters>[^)]+)\s*/i'; //$regex = '/(?P<function_name>.+)\s*\((?P<parameters>.*?)\)\s*/i/'; preg_match($regex, 'HOUR(`date`, \'abc1234\')', $matches); print_r($matches); $params = explode(',', $matches['parameters']); print_r(trim($params));
Output for 5.3.0 - 7.1.0
Array ( [0] => HOUR(`date`, 'abc1234' [function_name] => HOUR [1] => HOUR [parameters] => `date`, 'abc1234' [2] => `date`, 'abc1234' ) Warning: trim() expects parameter 1 to be string, array given in /in/NRnHq on line 16
Output for 4.3.3 - 5.2.17
Array ( [0] => HOUR(`date`, 'abc1234' [function_name] => HOUR [1] => HOUR [parameters] => `date`, 'abc1234' [2] => `date`, 'abc1234' ) Notice: Array to string conversion in /in/NRnHq on line 16 Array
Output for 4.3.0 - 4.3.2
Array ( [0] => HOUR(`date`, 'abc1234' [1] => HOUR [2] => `date`, 'abc1234' ) Notice: Undefined index: parameters in /in/NRnHq on line 15 Notice: Array to string conversion in /in/NRnHq on line 16 Array