phpstringstrpos

Strpos can never find needle in haystack while deriving needles from file()


for($i = 0; $i < 60; $i++)
{
    foreach($lines as $line_num => $line)
    {   
        if(strpos(strtolower($items[$i]['username']), strtolower($line)) !== false)
        {
            var_dump("found");
        }   
    }
}

I have 60 names in the $items array, for each name i'm checking it against another array containing names i'm looking for with strpos, however it NEVER seems to detect the string even though it's testing the following:

ashley.gram20 : ashley <- Does not show found.

It quite clearly should have found 'Ashley.gram20' surely? but it never does?

Thanks!


Solution

  • Solved! Thanks to @TML for giving me the nudge in the right direction, was simply some invisible character on the end of the string! (Not a space, which i'd already cleaned the string of).

    Now using:

    rtrim($target);
    

    While will trim all spaces and non standard chars from a string, the more you know!