underscore-php icon indicating copy to clipboard operation
underscore-php copied to clipboard

make sure needle is converted to string before calling strpos

Open madmuffin1 opened this issue 9 years ago • 0 comments

I had (a rather edge case) where Strings::startsWith was called from an Arrays::each closure similar to this:

$string = "12345";

Arrays::each([
    '1234' => "jey"
], function($value, $key) use ($string) {
    if(Strings::startsWith($string, $key)) {
        print_r("match");
    }
});

this would never match, since the key is automagically converted into an integer and strpos($haystack, INTEGER) will never match.

madmuffin1 avatar Sep 29 '15 12:09 madmuffin1