Perl grep require regular expression.
I think "grep -v" option given by sunpraveen will work only on shell.
I am using php function like preg_grep("/^(10.10.10.*)/",$ip_array).
So it requires pure regular explression.
Thanks anchal
My perl problem solved using your solution.however it's not working in php.
Some times i need to switch to php script. So i also need solution for php
// Get all ip's from router traffic data
$all_ips = read_file($all_traffic);
$local_ip = preg_grep("/10.10.10.*/",$all_ips);
//Remote ips are ip excluding ip range 10.10.10.*
$remote_ips = preg_grep("!/10.10.10/",$ip_arr);
//Display all Remote IP's
foreach($remote_ips as $key=>$ip)
{
echo $ip;
}
In the {} of your foreach loop, can you nest an if statement with a regex to filter out the local addresses? I do most of my programming in perl or ksh/bash so I'm not sure about the PHP syntax. Try this for the if condition:
if ( ! /10\.10\.10\. )
{
code
}
The . is a regex meta character and should be quoted in regular expressions when you use them in a literal sense.