smiley loading could cause invalid argument in foreach

smiley loading could cause invalid argument in foreach under certain conditions.  Thanks to Allan for the report; http://www.elkarte.net/community/index.php?topic=1943.0