Search code examples
phpvariablescoding-stylenaming-conventions

correct name for a variable users_ids vs user_ids


I ask you, native English speakers:

What is the correct name for a variable which contains ids of multiple users (from grammar point of view):

A) users_ids vs B) user_ids

I'm pretty sure C) users_id is wrong.

The variable is an array of ids:

array(12, 43, 12, 53)

and why?


Solution

  • $user_ids because it refers to a list of ids (plural), each belonging to a single user (singular). When looping through the ids I often use something like the following:

    $user_ids = array(12, 43, 12, 53);
    
    foreach($user_ids as $user_id) {
    // at this point $user_id refers to one id for one user
    }
    

    Besides, $user_ids is the most commonly used form (that I've seen).