Maybe provide a default value for $videos in case the foreach doesn't execute.