PHP 8.1.9 Released!

Voting

: max(one, four)?
(Example: nine)

The Note You're Voting On

Anonymous
9 years ago
The most straightforward way to prevent this function from returning 0 is:

  strpos('x'.$haystack, $needle, 1)

The 'x' is simply a garbage character which is only there to move everything 1 position.
The number 1 is there to make sure that this 'x' is ignored in the search.
This way, if $haystack starts with $needle, then the function returns 1 (rather than 0).

<< Back to user notes page

To Top