comparing actual IP with partial IP in PHP

Posted by aslum on Stack Overflow See other posts from Stack Overflow or by aslum
Published on 2010-04-15T20:49:14Z Indexed on 2010/04/15 20:53 UTC
Read the original article Hit count: 300

Using PHP I'd like to compare an actual ip address to part of one, and see if it matches. For example I want to see if the address matches 12.34..

<?php
$rem_address = getenv('REMOTE_ADDR');
$temp = substr ($rem_address,0,6)
if ($temp == "12.34.") echo "It's a match";
?>

Is there an easier/better way to do this?

© Stack Overflow or respective owner

Related posts about php

Related posts about ip-address