PHP detection array length function sizeof vs. Count usage

Source: Internet
Author: User

The Count:count () function calculates the number of cells in an array or the number of attributes in an object, returns the number of its elements for an array, returns 1 for other values,

If the argument is a variable and the variable is not defined, 0 is returned, and if mode is set to Count_recursive (or 1), the number of elements of the array in the multidimensional array is recursively computed.

sizeof: Definition and usage, the sizeof () function calculates the number of cells in an array or the number of attributes in an object.

Syntax: sizeof (Array,mode)

Parameters Describe
Array Required, specifies the array or object to count.
Mode Optional, specify the mode of the function, the possible values:
0-Default. Do not detect arrays in multidimensional arrays, arrays.
1-multidimensional array detection.

Note: The parameter mode is added in PHP 4.2.
Tip Count sizeof

Note: When the variable is not set, or the variable contains an empty array, the function returns 0, and the isset () variable can be used to test whether the variable is set.

PHP detection array length function sizeof vs. Count usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.