Replies: 7 comments
-
Whats the best way to check for non-/empty array? If you want wo compare to
|
Beta Was this translation helpful? Give feedback.
-
Not a whole lot of difference between |
Beta Was this translation helpful? Give feedback.
-
My personal preference is if (count($arr) === 1) {
//
} elseif (count($arr) === 2) {
//
} elseif (count($arr) > 0) {
//
} To me that is more readable than the proposed: if (count($arr) === 1) {
//
} elseif (count($arr) === 2) {
//
} elseif ( ! empty($arr)) {
//
} |
Beta Was this translation helpful? Give feedback.
-
I would also vote for using |
Beta Was this translation helpful? Give feedback.
-
Worth a read .... https://www.drupal.org/project/features/issues/3074109 |
Beta Was this translation helpful? Give feedback.
-
Just from readablity i'd also prefer |
Beta Was this translation helpful? Give feedback.
-
Exactly, "empty" is a right choice. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In many places magento calls count() just to check if array is empty.
These places should be changed to use !empty() instead.
Beta Was this translation helpful? Give feedback.
All reactions