Mega Code Archive

 
Categories / Php / Strings
 

Match an IP address

<? $test = "156.152.55.35"; if ( preg_match( "/(\d+)\.(\d+)\.(\d+)\.(\d+)/", $test, $array ) ) {   print "<pre>\n";   print_r( $array );   print "</pre>\n"; } ?>