How do I fix the "The each() function is deprecated" error?
Just update Drupal 7 to latest version which, as I am writing this answer, is version 7.64. Drupal 7 doesn't use each() in PHP since November 7, 2018, as the CHANGELOG.txt file says. (See the last line of the part I quoted.)


  Drupal 7.61, 2018-11-07
  
  
  File upload validation functions and hook_file_validate() implementations are
  now always passed the correct file URI.
  The default form cache expiration of 6 hours is now configurable (API
  addition: https://www.drupal.org/node/2857751).
  Allowed callers of drupal_http_request() to optionally specify an explicit
  Host header.
  Allowed the + character to appear in usernames.
  PHP 7.2: Fixed Archive_Tar incompatibility.
  PHP 7.2: Removed deprecated function each().
  


As long as you use at least Drupal 7.61, you will fix the error you shown, which (in your case) is caused from menu_set_active_trail(). (The code shown in the documentation page doesn't show any line using each() because the code has been updated to the latest Drupal 7 version.) 

If you are using third-party modules, you could still see that error, but caused by other functions/methods. In that case, you need to update all the modules you are using on that site.
If this doesn't fix other The each() function is deprecated errors, you need to check the issue queue for every third-party module you are using, and verify there are patches for fixing that error.