博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
count函数里加函数_PHP count()函数与示例
阅读量:2529 次
发布时间:2019-05-11

本文共 1413 字,大约阅读时间需要 4 分钟。

count函数里加函数

PHP count()函数 (PHP count() function)

"count() function" is used to get the total number of elements of an array.

“ count()函数”用于获取数组元素的总数。

Syntax:

句法:

count(array, [count_mode])

Here,

这里,

  • array is the name of an input array

    array是输入数组的名称

  • count_mode is an optional parameter and it's default value is 0, it has two values

    count_mode是一个可选参数,默认值为0,它有两个值

    0 – It does not count all elements of a multidimensional array

    0 –不计算多维数组的所有元素

    1 – It counts all elements of a multidimensional array

    1 –计算多维数组的所有元素

Examples:

例子:

Input:    $arr1 = array("101", "102", "103", "104", "105");    Output:    arr1 has 5 elements

PHP code: Using single dimensional array

PHP代码:使用一维数组

Output

输出量

arr1 has 5 elementsarr2 has 5 elements

PHP code: Using multidimensional array

PHP代码:使用多维数组

array( "name" => "Amit", "age" => 21, ), "102" => array( "name" => "Abhi", "age" => 20, ) ); $len = count($students); print ("count value = $len (count_mode is not provided)\n"); $len = count($students, 0); print ("count value = $len (count_mode is set to 0)\n"); $len = count($students, 1); print ("count value = $len (count_mode is set to 1)\n"); ?>

Output

输出量

count value = 2 (count_mode is not provided)count value = 2 (count_mode is set to 0)count value = 6 (count_mode is set to 1)

翻译自:

count函数里加函数

转载地址:http://bvtzd.baihongyu.com/

你可能感兴趣的文章
RocketMQ配置
查看>>
vs code调试console程序报错--preLaunchTask“build”
查看>>
蚂蚁金服井贤栋:用技术联手金融机构,形成服务小微的生态合力
查看>>
端口号大全
查看>>
机器学习基石笔记2——在何时可以使用机器学习(2)
查看>>
POJ 3740 Easy Finding (DLX模板)
查看>>
MySQL 处理重复数据
查看>>
关于typedef的用法总结(转)
查看>>
【strtok()】——分割字符串
查看>>
Linux下安装rabbitmq
查看>>
曹德旺
查看>>
【转】判断点在多边形内(matlab)
查看>>
java基础之集合:List Set Map的概述以及使用场景
查看>>
Python 线程 进程 协程
查看>>
iOS语言中的KVO机制
查看>>
excel第一次打开报错 向程序发送命令时出错 多种解决办法含终极解决方法
查看>>
响应式web设计之CSS3 Media Queries
查看>>
实验三
查看>>
机器码和字节码
查看>>
环形菜单的实现
查看>>