What exactly happens if I modify the $haystack inside such while (see subject) ? I realize that "don't do this" is good answer, and , but still, I am cusious know what happens if $haystack is modified (nobody does it conciensly). I see two-three possibilities (1) matching position is reset to 0 (2) matching position remains where it was.