Solution: in_array ip address explode not working

Author: Zeeshan Arshad     1519     07/23/2013

Estimated reading time: 0 minutes, 16 seconds

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';


Was this topic helpful?

Subscribe YouTube Channel

Zeeshan Arshad is a self-taught and multi-dimensional person with extraordinary track record of success with international clients and students.

Feel free to contact him for your project, training purpose or guidance.