I want to check if an entered input is a valid IP address or not. I would like a specific function that will help me validate a users input.
By using preg_match();
preg_match();
function checkIPAddress($ipAddress) { return preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $ipAddress); }