I'm creating a hit counter. The script that registers that the visitor was there creates a .txt file like this
IP Adress:127.0.0.1
Timestamp:1400602795
User Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36
Times visited:1
I want to be able to got information like timestamp and times visited. One way i'd like to do this is to create an array seperated by ":".
I tried to create the array, But for some reason "Times Visited" does not get included in the array. Here is the code from that attempt:
$fileResource = @fopen("hits/".$_SERVER["REMOTE_ADDR"].".txt","r");
$fileContent = @fread($fileResource,100000);
$array = preg_match_all("/(.*):(.*)\
/i",$fileContent,$fileMatches);
//0 = IP
//1 = Timestamp
//2 = User Agent
//3 = Times Visited
echo $fileMatches[0][3];
this is the output when i try print_r($fileMatches)
Array
( [0] => Array ( [0] => IP Adress:127.0.0.1
[1] => Timestamp:1400604101
[2] => User Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36
)
[1] => Array
(
[0] => IP Adress
[1] => Timestamp
[2] => User Agent
)
[2] => Array
(
[0] => 127.0.0.1
[1] => 1400604101
[2] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36
)
)