i have a roblam that need some new view.
i have a file that contain ip | country
what i am tring to do is to know how many ips i have from each country.
the file looks like that :
34.34.34.34 | US
34.24.24.24 | US
12.12.12.12 | UK
10.10.10.10 | FR
my out put should say that i have
3 countrys (US,UK,FR)
and in US 2 ips: ip,ip.
in UK 1 ip: ip.
in FR 1 ip: ip.
i mange to create array with string index for all the countrys
but from here i am stock.
please help
here is a bit of code i done so far
Expand|Select|Wrap|Line Numbers
- <?php
- $countrys = array();
- $file = "ip_list.txt";
- $handle = @fopen($file,"r");
- if ($handle) {
- while(!feof($handle)){
- $line = explode("|",fgets($handle, 4096));
- $countrys[$line[1]]=array();
- }
- echo count($countrys);
- print_r($countrys);
- ?>
go over the file agian and
Expand|Select|Wrap|Line Numbers
- if $line[1] == string_index //US==US
- then country["US"][0]= 34.34.34.34