Hi gg ... we meet again.
I'll assume that you can't use a db for this ... mysql is made for this type of storage.
The way to try and work these type of problems out is to imagine yourself doing it by hand and write down the procedure you use.
Imagine there's a huge number of names and a huge number of categories.
For example ...
(1) Open file.
(2) Read (next) line.
(3) Check for 'name' at beginning of current line. If not there, go back to step (2) and continue, otherwise ...
(4) Check for 'category' anywhere else on the line. If not there, go back to step (2) and continue, otherwise ...
(5) Find the current count for the 'found' name/category, add 1 to it and re-write the line.
(6) Stop.
The technicalities are all still to do ... for example, once you've updated the line, you have to join the 'file' array together again and save the whole thing back to the file.
See how you get on.
Paul.