I have a IPv6 address with port also [2401:2401:2401:2401:2401:2401:2401:2401]:1234
. I want to get the IPv6 address only in PHP. I am trying to do:
$str = "[2401:2401:2401:2401:2401:2401:2401:2401]:1234";
preg_match("[]", $str, $matches);
echo $matches[1];
But this does not get me the proper result.
I want matches[1]
to contain only "2401:2401:2401:2401:2401:2401:2401:2401"
.