Title: php error invalid argument for foreach()
Last modified: September 1, 2016

---

# php error invalid argument for foreach()

 *  Resolved [alevy5588](https://wordpress.org/support/users/alevy5588/)
 * (@alevy5588)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/php-error-invalid-argument-for-foreach/)
 * doing some debug work, and came across this error:
 * Invalid argument supplied for foreach() in /nas/content/staging/outputinc/wp-
   content/plugins/post-snippets/src/PostSnippets/WPEditor.php on line 189
 * changing the line from:
    `foreach ($snippets as $key => $snippet)`
 * to
 * `foreach ((array) $snippets as $key => $snippet)`
 * removed the warning and seems to have not broken any functionality, but I wanted
   to run this by some peers on here to see if there is anything I’m missing with
   this edit that may become hazardous.
 * [https://wordpress.org/plugins/post-snippets/](https://wordpress.org/plugins/post-snippets/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [alevy5588](https://wordpress.org/support/users/alevy5588/)
 * (@alevy5588)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/php-error-invalid-argument-for-foreach/#post-7549979)
 * solved

Viewing 1 replies (of 1 total)

The topic ‘php error invalid argument for foreach()’ is closed to new replies.

 * ![](https://ps.w.org/post-snippets/assets/icon-128x128.gif?rev=2545587)
 * [Post Snippets - Custom WordPress Code Snippets Customizer](https://wordpress.org/plugins/post-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/post-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-snippets/reviews/)

## Tags

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

 * 1 reply
 * 1 participant
 * Last reply from: [alevy5588](https://wordpress.org/support/users/alevy5588/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/php-error-invalid-argument-for-foreach/#post-7549979)
 * Status: resolved