Okay, here is what I am trying to do:
take a log.txt file and open it into an array.
txt file looks like this.
3213 login 23:04
1112 login 23:09
3211 logout 00:09
1344 login 01:09
3213 logout 01:12
then search the array for lines containing the user '3213' and display them to show that users activity. This is the code I have got so far:
$array = file('log.txt');
$search_for = 3213;
$key = array_search($search_for, $array);
print $array[$key];
unfortunately this only returns the first entry it comes across and I need it to print all the lines that include user 3213. I understand I probably have to use a loop here but have no idea how to do that properly in this case.
Thanks for reading
🙂