Use filter_var instead of preg_match (much better performance)
-
I do not know the reason why the big regular expression is used (and where it is from) to check if a string is an IPv6 address. Also I am not sure why the regular expression tries to match a string with optional whitespace characters at the beginning and end of it.
But I think filter_var with the correct flags is a much better and faster solution.
See the time values at https://3v4l.org/FS5fJ
- This topic was modified 3 years, 12 months ago by .
- This topic was modified 3 years, 12 months ago by .
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Use filter_var instead of preg_match (much better performance)’ is closed to new replies.