PHP preg match IP-adress check
Section: ScriptingRating: Not rated yet!

Add to YiGGAdd to google-bookmarksAdd to linkarenaAdd to redditAdd to del.icio.usAdd to misterwongAdd to digg




Introduction

This function checks if an input-value is an IP-adresse or not. It makes use of the regular-expression function preg_match.

<?php function IsIPAdress($value){ if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $value)){ return true; } return false; } if( IsIPAdress("192.168.0.1") ) echo("This is an IPAdress"); else echo("This is not an IPAdress"); ?>




 Reader-Comments: