You can use the PHP count() or sizeof() function to get the number of elements or values in an array. The count() and sizeof() method returns 0 for a variable that has been initialized with an empty array. If the array is not initialized, you will see an error. In that case, you can use the isset() function to check whether a variable is set or not.

Advertisement

Using sizeof():

Using count():

Share.
Leave A Reply


Exit mobile version