To account for the case that jrhodes has pointed out, we can change the line to:
substr_count ( implode( ',', $haystackArray ), $needle );
This way:
array (
0 => "mystringth",
1 => "atislong"
);
Becomes
mystringth,atislong
Which brings the count for $needle = "that" to 0 again.