| | 13 | |
| | 14 | /** |
| | 15 | * Return a callback array from a string, eg: limit[10,20] would become |
| | 16 | * array('limit', array('10', '20')) |
| | 17 | * |
| | 18 | * @param string callback string |
| | 19 | * @return array |
| | 20 | */ |
| | 21 | public function callback_string($str) |
| | 22 | { |
| | 23 | // command[param,param] |
| | 24 | if (preg_match('/([^\[]*+)\[(.+)\]/', (string) $str, $match)) |
| | 25 | { |
| | 26 | // command |
| | 27 | $command = $match[1]; |
| | 28 | |
| | 29 | // param,param |
| | 30 | $params = preg_split('/(?<!\\\\),/', $match[2]); |
| | 31 | $params = str_replace('\,', ',', $params); |
| | 32 | } |
| | 33 | else |
| | 34 | { |
| | 35 | // command |
| | 36 | $command = $str; |
| | 37 | |
| | 38 | // No params |
| | 39 | $params = NULL; |
| | 40 | } |
| | 41 | |
| | 42 | return array($command, $params); |
| | 43 | } |