Hello,
if(strpos($content,'Some sentence.')){
die('ok');
}else{
die('not ok');
}
It’s never ok. However, if I remove the first letter of the sentence, that is the capital “S”, it returns ok. Why is that?
$content come from a .doc file.
Regards,
-jj. 
I don’t know. What’s the content of $content?
Occurrence of the piece of the string you were looking for can be at the position 0, which doesn’t evaluate as true and which is what strpos MIGHT return.
So, you need to check whether strpos returned false or if it returned an integer that holds the position where the needle was found.
Before checking what’s wrong with your $content variable, try to use
if(strpos($content,'Some sentence.') !== false){
die('ok');
}else{
die('not ok');
}
yep, occurence of the string is at the very beginning of $content.
I will try it. Thanks for the reply.
> $content come from a .doc file.
that’s a word processor file right? not plain text. your code is looking for the string in the bytes of the data literally. a format like .doc (presumably, i don’t know much about .doc format) will not contain the text straight forwardly. e.g. in rich text format, the bytes of the file which contains just the word hello, with the llo in red is (hexdump with ascii on the right between |'s):
....
....
00000140 66 73 32 34 20 5c 63 66 30 20 68 65 5c 63 66 32 |fs24 \\cf0 he\\cf2|
00000150 20 6c 6c 6f 7d | llo}|
see near the end there’s he and llo separate. i haven’t got a clue what happens in a .doc file but presumably something similar is happening.
try examining the contents of the file in question – its bytes. the command line utility (on os x at least) is good for this.
hexdump -C /path/to/file.doc
outputs the same type of output i quoted above