Solution: in_array ip address explode not working

Author: Zeeshan Arshad     1954     07/23/2013

Estimated reading time: 0 minutes, 16 seconds

Zeeshan Arshad - Lifestyle Blog

Problem: You are trying to match an IP address against multiple IP addresses using explode() but it's not working.


$ip_addresses = ',,';

// Allowed
if (in_array($_SERVER['REMOTE_ADDR'], array_map("trim", explode(',', $ip_addresses)))) {

echo 'ip address was found in array';

// Blocked
} else {

echo 'ip address was not found in array';


« Return to Blog