Jump to content

What Is Haystack And Needle?


hunglduc

Recommended Posts

It's a metaphore... haven't you heared the saying "It's like trying to find a needle in a haystack."?So, when you say for example:

int strpos ( string $haystack , mixed $needle [, int $offset= 0 ] )

The $needle is what you're looking for, and the $haystack is the place where you're looking for it. In this case:

strpos('abcd', 'a');

will search 'abcd' for the string 'a', and since 'a' is the first character in the string, the function call above will return 0.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...