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

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

sizeof函数

PHP sizeof()函数 (PHP sizeof() function)

sizeof() function is an alias of , it is used to get the total number of elements of an array.

sizeof()函数是的别名,用于获取数组元素的总数。

Syntax:

句法:

sizeof(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 = sizeof($students); print ("sizeof value = $len (sizeof_mode is not provided)\n"); $len = sizeof($students, 0); print ("sizeof value = $len (sizeof_mode is set to 0)\n"); $len = sizeof($students, 1); print ("sizeof value = $len (sizeof_mode is set to 1)\n"); ?>

Output

输出量

sizeof value = 2 (sizeof_mode is not provided)sizeof value = 2 (sizeof_mode is set to 0)sizeof value = 6 (sizeof_mode is set to 1)

翻译自:

sizeof函数

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

你可能感兴趣的文章
APP开发手记01(app与web的困惑)
查看>>
笛卡尔遗传规划Cartesian Genetic Programming (CGP)简单理解(1)
查看>>
mysql 日期时间运算函数(转)
查看>>
初识前端作业1
查看>>
为啥程序会有bug?
查看>>
跨域技术
查看>>
JS里的居民们7-对象和数组转换
查看>>
计算两个日期的时间间隔,返回的是时间间隔的日期差的绝对值.
查看>>
python初体验
查看>>
配置vue,vue脚手架的应用(老版本)
查看>>
linux下防火墙iptables原理及使用
查看>>
经典C面试真题精讲
查看>>
Remove Duplicates from Sorted List解题报告
查看>>
ffmpeg格式转换命令
查看>>
万方数据知识平台 TFHpple +Xpath解析
查看>>
Hive实现oracle的Minus函数
查看>>
秒杀多线程第四篇 一个经典的多线程同步问题
查看>>
RocketMQ配置
查看>>
vs code调试console程序报错--preLaunchTask“build”
查看>>
蚂蚁金服井贤栋:用技术联手金融机构,形成服务小微的生态合力
查看>>