read 8x4 photocell matrix

I want to read a a 8x5 (=40) photocell matrix with using as few pins possible (preferably max 8).

My first idea was:
send 5v to the first line of 8 photocells, read the output with a parallel->serial IC 74HC165
send 5v to the second line ...

this could be done via 5 select + 3 data wires for the one 74HC165.

But 74HC165 is digital read, and idea how to approach my problem.
The best solution for me would be to read a serial string of 40 analog read, but I am opened to other solution (5 inputs...).

Any ideas/suggestions?