Php: sizeofcount_PHP, a function for detecting the length of an array

Source: Internet
Author: User
Php checks the sizeofcount function of the array length. The php Tutorial detects the array length function sizeofcount. the php function detects the array length by sizeofcount. see a simple example * $ colorlistarray (applered, grassgreen, skyblue, the nigh php Tutorial detects the array length function sizeof count.
The function used to check the length of the array in php is sizeof count. check a simple instance */
$ Colorlist = array ("apple" => "red", "grass" => "green", "sky" => "blue ", "night" => "black", "wall" => "white ");

Echo "array length:". count ($ colorlist); // 5

/*
Count

The count () function calculates the number of units in the array or the number of attributes in the object.

For an array, return the number of its elements. for other values, return 1. If the parameter is a variable but the variable is not defined, 0 is returned. If the mode is set to count_recursive (or 1), the number of elements in the array in the multi-dimensional array is calculated recursively.

Sizeof
Definition and usage
The sizeof () function calculates the number of units in the array or the number of attributes in the object.

Syntax
Sizeof (array, mode) parameter description
Array is required. Specifies the array or object to be counted.
Mode is optional. Specifies the function mode. Possible values:

0-default. Multi-dimensional arrays (arrays in arrays) are not detected ).
1-multi-dimensional array detection.
Note: this parameter is added to php 4.2.

Prompt count sizeof
Note: If the variable is not set or contains an empty array, the function returns 0. You can use the isset () variable to test whether the variable is set.


The limit count function in php detects the length of an array. For more information, see the following simple example: */$ colorlist = array (apple = red, grass = green, sky = blue, nigh...

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.