Count () and sizeof () in PHP

Source: Internet
Author: User

The Get array length function in PHP has two count () and sizeof (), if the array passed to the function is an empty array, or a variable that is not set, the number of elements returned is 0;
Like the function of two functions, the manual says that sizeof () is the alias of the function count ().

Count (Array,mode), count () function two parameters, array is required, mode indicates whether recursion is required to calculate the number of elements in the array, is not required, default is 0. That is not required. When array is a one-dimensional array, mode is not used, and when array is a multidimensional array, mode is 0, the number of first-level arrays is computed, mode is 1, and the number of all arrays is computed. For example, array $cars,count ($cars) = 3;count ($car, 1) =3+5=8.

$cars =array ("    Volvo" =>array ("        XC60",        "XC90"    ),    "BMW" =>array (        "X3",        "X5"    ),    "Toyota" =>array (        "Highlander")    );

  

Count () and sizeof () in PHP

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.