Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 329747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:37:01+00:00 2026-05-12T09:37:01+00:00

I have the following arrays below in PHP that I store a user_id number

  • 0

I have the following arrays below in PHP that I store a user_id number in to keep track of moderator/admins on my site, then in a page I can just use in_array() to determine if a user should have moderator privileges, I figure this saves some mysql queries by using an array instead.

I am wondering, would there be any performance gain from combining these into 1 bigger array instead of seperate ones?

If so could you show an example how I can combine them and use it?

Maybe list some reasons for 1 way over the other?

$moderators = array(1,99,88,77,2,3,4,5);
$bulletin_moderators = array(1,1091,13,103);
$forum_moderators = array(1,1091,34850,13,103,21);
$blog_moderators = array(1,1091,21);
$photo_moderators = array(1,1091,13,34850,103,21);
$chat_moderators = array(1,44534);
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:37:01+00:00Added an answer on May 12, 2026 at 9:37 am

    Performance gain? No. Maintainability gain? Definitely. Try this:

    $roles=array(
        'moderators'          => array(1,99,88,77,2,3,4,5),
        'bulletin_moderators' => array(1,1091,13,103),
        'forum_moderators'    => array(1,1091,34850,13,103,21),
        'blog_moderators'     => array(1,1091,21),
        'photo_moderators'    => array(1,1091,13,34850,103,21),
        'chat_moderators'     => array(1,44534)
    );
    

    As the above poster said though, these really shouldn’t be hardcoded. A DB query wouldn’t take any significant amount of time, and it would probably be cached in memory or in the database itself (assuming you use mysql).

    What if you add more users? You would have to edit your source. What if you had multiple servers? You would have to edit your source on X amount of servers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following two arrays. I want the difference between these two arrays. That
I have the following arrays in PHP (okay they are a bit bigger but
I have the following 2 arrays that I'm trying to merge recursively so that
I have a db.php file that has the following in it: // db.php file
I have the following php code that runs after validation: try { if (isset($filtered)
I am using PHP 5.3.6 I have the following code below. Everything works fine
I have the following 2 arrays and would like to combine them. I'm more
I have the following string arrays: var array1 = new String[] { A, B,
I have the following three arrays and need to create a new two-dimensional array
I have the following issue: A java object contains two arrays of core datastore

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.