It'd be much easier to do with grep but it's fairly straightforward in php as well. Code: <?php //The file that you want to count downloads of $filename = 'test.gif ...