preg_match_all("/<img.*>/", $htmlfile, $match);
Since PCRE_DOTALL is not used, this pattern is expected to NOT make matches across multiple lines. However, in somecases it can, depending on the PCRE default settings and your data ($htmlfile). The problem is that some are set to recognize NEWLINES differently.
To fix this use,
preg_match_all("/(*ANY)<img.*>/", $htmlfile, $match);
Now, any character that could possibly be seen as a newline will be interpreted as a newline by the PCRE.
NOTE: This pattern has been available since PCRE version 7.3