![]() |
Indentation style of an array
I am merely wondering as to how people indent their arrays. For example, when you have an array with some pretty substantial lines, putting it all on one line isn't usually the greatest style in the world because you then get stupidly long lines.
I used to format my arrays like the following: php Code:
But even that is wasting so much white-space to the left of each item. Therefore recently I've been using the following styling method which I feel is far better: php Code:
This is taken from the way I format my Javascript dynamic functions, like so: javascript Code:
How do you go about indenting your arrays? I'm curious :-) |
I too followed the first method for some time, but also changed to the latter for the exact same reason. However, now I've updated my monitor it doesn't really bother me either way.
The only downside to the second method is that the blocks kind of look like functions at a glance, but that is really a very minor hindrance. There is another alternative: PHP Code:
|
I'm going with this style (extras from a piece of code of mine, I'm too lazy to come up with something right now :D):
PHP Code:
|
Yep. Technically a zero terminated string which doesn't apply in PHP. But to me it looks a lot nicer than
$sVariable. |
PHP Code:
|
I do it like what Karl posted. I keep it to the left, however I add one tab, and keep the parentheses for array() on the line with something else, so as to not add too many unneeded lines.
|
PHP Code:
|
I generally follow a similar approach to the last post, by sjaq, except that indent depths are always the same (one tab; don't hate me for using tabs) whereas the initial indent is double the length in the code posted above.
I know the following is not strictly about indentation, but I feel it applies here. I like to keep all of the 'key value' ( =>) operators nicely lined up as well (using spaces as padding).All in all, it's just personal preference and one that I've adopted over time. PHP Code:
|
| All times are GMT. The time now is 07:59 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0