3v4l.org

run code in 300+ PHP versions simultaneously
<?php const DNS_LABEL = '(?:[a-z0-9]|[a-z0-9][a-z0-9\-]{0,61}[a-z0-9])'; const DNS_NAME = '(?:' . DNS_LABEL . '\.)*' . DNS_LABEL; $input = 'bar.foo.com:443'; // $_SERVER['HTTP_HOST'] if (!\preg_match('(^(' . DNS_NAME . ')(?::[0-9]+)?$)i', $input, $match)) { throw new Exception('Not a valid DNS-based HTTP Host header'); } $lastTwoLabels = implode('.', array_slice(explode('.', $match[1]), -2)); var_dump($lastTwoLabels);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
171.79 ms | 2541 KiB | 15 Q