Title: PHP error 157
Last modified: March 9, 2021

---

# PHP error 157

 *  Resolved [paolo1992](https://wordpress.org/support/users/paolo1992/)
 * (@paolo1992)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/)
 * The following error me to:
 * Warning: Invalid argument supplied for foreach() in /home/ccchso5/public_html/
   wp-content/plugins/popup-builder/com/classes/components/Menu.php on line 157
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-error-157-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [clickingclients](https://wordpress.org/support/users/clickingclients/)
 * (@clickingclients)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14157997)
 * I have the same issue on update to Version 3.77.
    It errors when **foreach** 
   is trying to access empty array on line 157. Please add the check and update 
   the code soon: **if(!empty($menuItems)){**
 *     ```
       public function getNavMenuItemsWithPopup($navMenuLocations = array(), $forceUpdate = false)
           {
       		if (!isset(self::$navMenuItems) && !$forceUpdate) {
       			foreach ($navMenuLocations as $menuName => $menuId) {
       				$menuItems = wp_get_nav_menu_items($menuId);
       				if(!empty($menuItems)){
       					foreach ($menuItems as $menuItem) {
       						$popupId = $menuItem->sgpbPopupId;
       						if ($popupId > 0) {
       							self::$navMenuItems[] = $menuItem;
       						}
       					}
       				}
       			}
       		}
   
       		return isset(self::$navMenuItems) ? self::$navMenuItems : array();
       	}
       ```
   
    -  This reply was modified 5 years, 2 months ago by [clickingclients](https://wordpress.org/support/users/clickingclients/).
    -  This reply was modified 5 years, 2 months ago by [clickingclients](https://wordpress.org/support/users/clickingclients/).
 *  [Andy Galaxy](https://wordpress.org/support/users/andy-galaxy/)
 * (@andy-galaxy)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14158839)
 * I’m getting the following PHP error as well.
 * Warning: Invalid argument supplied for foreach() in /home/ccchso5/public_html/
   wp-content/plugins/popup-builder/com/classes/components/Menu.php on line 157
 * Popup Builder v 3.77
 *  [twistedfngrs](https://wordpress.org/support/users/twistedfngrs/)
 * (@twistedfngrs)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14160215)
 * Same issue, please fix this ASAP.
 *  [birdsflyfree](https://wordpress.org/support/users/birdsflyfree/)
 * (@birdsflyfree)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14160326)
 * I have the same error:
 * Warning: Invalid argument supplied for foreach() in /home/customer/www/stoodleighcourtcoachhouse.
   co.uk/public_html/wp-content/plugins/popup-builder/com/classes/components/Menu.
   php on line 157
 * Please fix ASAP
    -  This reply was modified 5 years, 2 months ago by [birdsflyfree](https://wordpress.org/support/users/birdsflyfree/).
 *  [Sygnoos Support](https://wordpress.org/support/users/sygnoossupport/)
 * (@sygnoossupport)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14160580)
 * Dear [@birdsflyfree](https://wordpress.org/support/users/birdsflyfree/) , [@twistedfngrs](https://wordpress.org/support/users/twistedfngrs/),
   [@andy-galaxy](https://wordpress.org/support/users/andy-galaxy/), [@clickingclients](https://wordpress.org/support/users/clickingclients/)
   and [@paolo1992](https://wordpress.org/support/users/paolo1992/)
 * Thanks for reporting.
    This is to inform you, that the issue is solved with the
   latest 3.78 version of the plugin. Please, update it and let us know if that 
   helped.
 *  [Andy Galaxy](https://wordpress.org/support/users/andy-galaxy/)
 * (@andy-galaxy)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14163078)
 * Well done! No error now. Thanks for prompt fix. Chers, Andy
 *  [clickingclients](https://wordpress.org/support/users/clickingclients/)
 * (@clickingclients)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14163335)
 * Thanks for getting this done. Glad my code helped.
 *  [birdsflyfree](https://wordpress.org/support/users/birdsflyfree/)
 * (@birdsflyfree)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14163376)
 * Fab! No error now! Thanks for your speedy response! 🙂
 *  [Andy Galaxy](https://wordpress.org/support/users/andy-galaxy/)
 * (@andy-galaxy)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14163381)
 * Awesome plugin by the way. Keep up the good work.
    -  This reply was modified 5 years, 2 months ago by [Andy Galaxy](https://wordpress.org/support/users/andy-galaxy/).
 *  [Sygnoos Support](https://wordpress.org/support/users/sygnoossupport/)
 * (@sygnoossupport)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14166307)
 * Thanks for the update 🙂
    We are happy the issue is gone now. Thanks for the 
   nice words as well. We will keep improving the plugin.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘PHP error 157’ is closed to new replies.

 * ![](https://ps.w.org/popup-builder/assets/icon-128x128.gif?rev=2698840)
 * [Popup Builder - Create highly converting, mobile friendly marketing popups.](https://wordpress.org/plugins/popup-builder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/popup-builder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/popup-builder/)
 * [Active Topics](https://wordpress.org/support/plugin/popup-builder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/popup-builder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/popup-builder/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [update error](https://wordpress.org/support/topic-tag/update-error/)

 * 10 replies
 * 6 participants
 * Last reply from: [Sygnoos Support](https://wordpress.org/support/users/sygnoossupport/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/php-error-157-2/#post-14166307)
 * Status: resolved