I just need to check if an array has more than one element.
I am trying to do it this way :
if (isset($arr['1']))
the other traditional way is
if (sizeof($arr)>1)
Which of the two is better? In such situaions, how should I judge between two alternate methods?
Is there any performance check meter available to measure which is better?
Use this
Or
sizeof()is an alias forcount(), they work the same.Edit:
Answering the second part of the question:
The two lines of code in the question are not alternative methods, they perform different functions. The first checks if the value at
$arr['1']is set, while the second returns the number of elements in the array.