Title: in_array function performance
Last modified: March 18, 2022

---

# in_array function performance

 *  Resolved [Richard Venancio](https://wordpress.org/support/users/richardvenancio/)
 * (@richardvenancio)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/in_array-function-performance/)
 * Hello guys, it is just a suggestion:
 * On class-swpm-protection-base.php you check if the post is protected using in_array
   function, on a big portal with thousands posts protected this gonna have a performance
   issue.
 * For the future if you think it worst, you could create the array as an associative
   array, and use isset, to check if the post is protected.
 *     ```
       $array = [
        '1548' => 1',
        '116515' => 1',
        '851312' => 1',
        '415511' => 1',
        '651322' => 1',
        '651321' => 1',
       ];
   
       return isset($array[$post_id]);
       ```
   
    -  This topic was modified 4 years, 2 months ago by [Richard Venancio](https://wordpress.org/support/users/richardvenancio/).
    -  This topic was modified 4 years, 2 months ago by [Richard Venancio](https://wordpress.org/support/users/richardvenancio/).

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

 *  Plugin Support [mbrsolution](https://wordpress.org/support/users/mbrsolution/)
 * (@mbrsolution)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/in_array-function-performance/#post-15474156)
 * Hi, thank you for reaching out to us and providing your suggestion. I have submitted
   a message to the developers to investigate further your code.
 * Kind regards.
 *  Plugin Author [wp.insider](https://wordpress.org/support/users/wpinsider-1/)
 * (@wpinsider-1)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/in_array-function-performance/#post-15479082)
 * Thank you. We will check it out.

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

The topic ‘in_array function performance’ is closed to new replies.

 * ![](https://ps.w.org/simple-membership/assets/icon-128x128.png?rev=974529)
 * [Simple Membership](https://wordpress.org/plugins/simple-membership/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-membership/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-membership/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-membership/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-membership/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-membership/reviews/)

## Tags

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

 * 2 replies
 * 3 participants
 * Last reply from: [wp.insider](https://wordpress.org/support/users/wpinsider-1/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/in_array-function-performance/#post-15479082)
 * Status: resolved