Re: how to check REMOTE_ADDR to see if it contains PART of an ip

From: Date: Wed, 16 Jan 2002 23:47:20 +0000
Subject: Re: how to check REMOTE_ADDR to see if it contains PART of an ip
Groups: php.general 
Request: Send a blank email to php-general+get-80857@lists.php.net to get a copy of this message
yeah, like strpos() you still could have gotten from the manual. strncmp() does it exactly, like strpos() but only searches the beginning, note that it returns false for matching strings for use in some sorting functions. <?php $testip = "150.200.250.x"; $match = "150.200.250."; if (!strncmp($testip, $match, strlen($match))) { echo("ok, " . $testip . " matches"); } ?> bvr. On Wed, 16 Jan 2002 10:58:16 -0800 (PST), Police Trainee wrote: >nah, there's another one that you don't have to >speficy the length. i remember seeing it used once >when checking the user's browser to see if the string >"mozilla" was contained within the variable... > >besides, i changed the string to check for by one >digit and it still returned true because PART of the >string was true i guess... i dunno. > >anyone else got another function in mind? >--- "bvr@xs4all.nl" <bvr@xs4all.nl> wrote: >> >> >> strncmp() >> >> MANUAL! >> >> bvr.

« previous php.general (#80857) next »