php: functions to read files from directory and filter them