string - Retain case when using str_ireplace? -
I am creating a search that searches the text
str_ireplace ($ q, '& lt; span & gt;' $ q. '& Lt; / Span & gt; ', $ row [name]);
The problem is that if a user searches for Tom
then Tom
will show that is cool, but if they Tom
will show tom
because of str_ireplace
, does this make sense? The real issue is that if someone records Tom ARNFAL
, though this will do the right thing, the aesthetics are actually Page Tom ARNFAL
Should I retain the capital letter of both the stars and the lower case? Is there a better way to wrap the insensitive text from a string?
a stack of grass, case insensitive
< Pre> $ keyword_caseRetained_all = stristr ($ numerator, $ keyword);
But it also gives the needle and the cover of the remaining grass, so you only have to use substrost to keep the needle part. Start at the position of 0, Reach the length of the keyword
$ keyword_caseRetained = substr ($ keyword_caseRetained_all, 0, strlen ($ keyword));
Now use that variable within the stringhellest function
$ excerpt = str_ireplace ($ keyword, '& lt; em & gt;' $ keyword_caseRetained . '& Lt; / em>; $ fraction);
Once you know this, you can add lines 1 and 2 to a good mice to minimize your code.
Or add it as a method in the string manipulation class.
Comments
Post a Comment