Replaced filter_var function with native implementation from https://github.com/javazac/filter_var