The term "haystack" in the context of PHP
There are a few PHP functions (such as strstr, strpos and strrchr) that accept
a parameter named $haystack
. Where开发者_如何学Go does this name come from?
It comes from the idiom "needle in a haystack". The needle is the item you're searching for (in this case the substring, or search string), the haystack is what the needle is located within (in this case the input string).
Edit (pst - to visualize answer):
Finding a needle in a haystack. You are looking for a substring in a bigger string.
A Needle in a haystack is a figure of speech used to refer to something that is difficult to locate in a much larger space. - wiki
精彩评论