Not much use in blanking the array each time
Use strpos in place of substr