Assuming that create_array
returns a PHP array, then count
is "Just as Fast" - or rather, both operations are O(1) - and does not depend upon the size of the array. This is because arrays store their size internally.
That being said, if create_array
returns an arbitrary Countable, then the count
may have to do more work, depending upon how the returned object is implemented - imagine if an object implemented as a Single-Linked List was returned; this would require O(n) time to count.
In any case, using empty
is more semantically clear and, as shown by a small micro-benchmark by Darragh, performs the same as isset in wall-clock time.
See also: Is PHP's count() function O(1) or O(n) for arrays?