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?
I use the plural form. Then I can do something like:
$name = $names[1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With