Chcę wyszukać wszystkie słowa Jedno i dwuliterowe w tekscie i robię to tak:
$text = 'A It seems to me like using a REGEX in this case would just be overkill. Why not just just strpos to find the space character. Also, theres nothing special about the space character in regular expressions, you should be able to search for it the same as you would search for any other character. That is, unless you disabled pattern whitespace, which would hardly be necessary in this case.';
A funkcja zwraca głupoty:
[0]=>
[0]=>
string(4) " to "
[1]=>
string(6) " like "
[2]=>
string(4) " in "
[3]=>
string(6) " case "
[4]=>
string(6) " just "
[5]=>
string(6) " just "
[6]=>
string(4) " to "
[7]=>
string(4) " in "
[8]=>
string(4) " be "
[9]=>
string(4) " to "
[10]=>
string(4) " it "
[11]=>
string(6) " same "
[12]=>
string(4) " be "
[13]=>
string(4) " in "
}
[1]=>
[0]=>
string(2) "to"
[1]=>
string(2) "ke"
[2]=>
string(2) "in"
[3]=>
string(2) "se"
[4]=>
string(2) "st"
[5]=>
string(2) "st"
[6]=>
string(2) "to"
[7]=>
string(2) "in"
[8]=>
string(2) "be"
[9]=>
string(2) "to"
[10]=>
string(2) "it"
[11]=>
string(2) "me"
[12]=>
string(2) "be"
[13]=>
string(2) "in"
}
}
Czemu zwraca końcówki od wyrazów, a nie zwraca np pierwszego wyrazu jakim jestA