Strpos usage
Strpos (String,find,start)
Let's look at a piece of code Strpos:
Ajax get participle
Public Function Get_segment_words () {
$title = I (' title ');
$content = I (' content ');
$Segment = M (' Segment ');
$Segment _content = M (' segment_content ');
$segment _array = $Segment->getfield (' Id,word ');
$setment _words = Array ();
foreach ($segment _array as $id => $word) {
if (False!== Strpos ($content, $word) | | false!== strpos ($title, $word)) {
$segment _words[] = $word;
}
}
$segment _words = Array_unique ($segment _words);
$segment _words = Implode (', ', $segment _words);
echo $segment _words;exit; Ajax Get Padding
}
Note This code:
if (False!== Strpos ($content, $word) | | false!== strpos ($title, $word)) {
Todo
}
If the match fails, STRPOS returns the bool type of false, which must be noted. What else would happen? If you want to match the character exactly in the first position, for Strpos this function is to return 0, that is, position 0. This time is actually a match, the result returns 0, if this is wrong to judge:
if (!strpos ($content, $word))
As an example:
Content: Shopping bag Vandersafara Dot van der Sar.
Matching: Shopping
If you want to find out whether there is "shopping" in the content of two words, Strpos will return 0, indicating the existence of "shopping" two words, the position is 0.
Therefore, the False!=strpos ($find, $content) is used to determine whether the match was successful.