Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you name your arrays using plural or singular in PHP? [closed]

When I'm naming array-type variables, I often am confronted with a dilemma: Do I name my array using plural or singular?

For example, let's say I have an array of names: In PHP I would say: $names=array("Alice","Bobby","Charles");

However, then lets say I want to reference a name in this array. For Bobby, I'd say: $names[1]. However, this seams counter-intuitive. I'd rather call Bobby $name[1], because Bobby is only one name.

So, you can see a slight discrepancy. Are there conventions for naming arrays?

like image 573
stalepretzel Avatar asked Dec 28 '08 03:12

stalepretzel


1 Answers

I use the plural form. Then I can do something like:

$name = $names[1]; 
like image 64
tvanfosson Avatar answered Oct 21 '22 00:10

tvanfosson