PHP function for detecting array length sizeof count_php tutorial

Source: Internet
Author: User
PHP Tutorial detects array length of function sizeof count
The function of detecting array length in PHP has sizeof count below to see a simple instance */
$colorlist = Array ("Apple" = "red", "grass" = "green", "sky" = "Blue", "Night" = "Black", "wall" and "white" );

echo "Array length is:". Count ($colorlist); 5

/*
Count

The count () function calculates the number of cells in an array or the number of properties in an object.

For an array, returns the number of its elements, and returns 1 for other values. Returns 0 if the argument is a variable and the variable is not defined. If mode is set to Count_recursive (or 1), the number of elements in 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 properties in an object.

Grammar
sizeof (array,mode) parameter description
Array required. Specifies the array or object to count.
mode is optional. Specifies the mode of the function. Possible values:

0-Default. multidimensional arrays (arrays in arrays) are not instrumented.
1-multidimensional array detection.
Note: This parameter was added to PHP 4.2.

Tip Count sizeof
Note: When the variable is not set, or the variable contains an empty array, the function returns 0. You can use the Isset () variable to test whether a variable is set.


http://www.bkjia.com/PHPjc/445398.html www.bkjia.com true http://www.bkjia.com/PHPjc/445398.html techarticle PHP Tutorial detects array length function sizeof count in PHP the function of detecting array length has sizeof count below to see a simple instance */$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.