3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str1 = "— lorem lorem Alice lorem lorem lorem loremlorem"; // | < Why would a dash make a difference in the the found index? $str2 = "a lorem lorem Alice lorem lorem lorem loremlorem"; $str3 = " lorem lorem Alice lorem lorem lorem loremlorem"; // The found index is always the same $foundIndex = mb_stripos($str1, "Alice"); var_dump(substr($str1, $foundIndex - 6, 24), $foundIndex); $foundIndex = mb_stripos($str2, "Alice"); var_dump(substr($str2, $foundIndex - 6, 24), $foundIndex); $foundIndex = mb_stripos($str3, "Alice"); var_dump(substr($str3, $foundIndex - 6, 24), $foundIndex);

preferences:
63.29 ms | 402 KiB | 5 Q