- preg_match_all: documentation ( source)
- implode: documentation ( source)
<?php
$ipString = 'ffff:heee:dddd:cccc:bbbb:aaaa:9999:8888';
$test = array();
preg_match_all("/(?U:[a-f0-9]+:?)+/", $ipString, $test);
if(count($test) > 1 || count($test[0]) > 8){
echo false;
}else{
if(implode(':', $test[0]) !== $ipString){
echo false;
}
}
echo true;
?>