I am testing the matching of a function I am using to check IP ranges.
$a = "75.1.";
$b = "75.142.3.8";
$num = preg_match("/^$a/", $b, $matches);
echo "$a<br/>\n$b<br/>\n$num";
This is returning a $num of 1 for me. Why is this returning a match, despite "1." not matching "142"? Am I making some error with regular expressions? strstr($b, $a) and str_starts_with($b, $a) are both returning FALSE, as I was expecting.
>Solution :
. is a wild character, you’ll need to escape it with a \
$a = "75\.1\.";