3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = 'aaaaaaaaaa.bbbbbbbbbbb.cccccccccccc.dddddddddd.eeeeeeeeee.fffffffff.gggggggggg.hhhhhhhhh'; $max = 10; $retry = 1; do { echo $test . "\n"; // preg_match("/^.+?\.(.+)$/", $test, $result); // if (0 === preg_match("/^.+?\.(.+)$/", $test, $matches)) throw new \InvalidArgumentException('invalid'); if (0 === preg_match("/^[^.]+\.(.+)$/", $test, $matches)) throw new \InvalidArgumentException('invalid'); $test = $matches[1]; } while ($retry++ < $max);

preferences:
54.14 ms | 402 KiB | 5 Q