1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Use Regex-class

This commit is contained in:
Tim Düsterhus 2011-12-23 20:28:09 +01:00
parent 80daee9c46
commit b15f4aca16

View File

@ -72,7 +72,10 @@ public static function str_split($string, $length = 1) {
* @return integer
*/
public static function timeModifier($time) {
preg_match_all('!([0-9]+[s|h|d|w|m|y]?)!i', $time, $matches);
$regex = new \wcf\system\Regex('([0-9]+[s|h|d|w|m|y]?)', \wcf\system\Regex::CASE_INSENSITIVE);
if (!$regex->match($time, true)) return 0;
$matches = $regex->getMatches();
$result = 0;
foreach ($matches[1] as $time) {
// 60 seconds a minute