PHP sizeof() 函数
PHP 教程
· 2019-01-22 22:58:59
实例
返回数组中元素的数目:
<?php
$cars=array("Volvo","BMW","Toyota");
echo sizeof($cars);
?>
$cars=array("Volvo","BMW","Toyota");
echo sizeof($cars);
?>
定义和用法
sizeof() 函数返回数组中元素的数目。
sizeof() 函数是 count() 函数的别名。
语法
sizeof(array,mode);
| 参数 | 描述 |
|---|---|
| array | 必需。规定要计数的数组。 |
| mode | 可选。规定函数的模式。可能的值:
|
技术细节
| 返回值: | 返回数组中元素的数目。 |
|---|---|
| PHP 版本: | 4+ |
更多实例
实例 1
递归地计算数组中元素的数目:
<?php
$cars=array
(
"Volvo"=>array
(
"XC60",
"XC90"
),
"BMW"=>array
(
"X3",
"X5"
),
"Toyota"=>array
(
"Highlander"
)
);
echo "Normal count: " . sizeof($cars)."<br>";
echo "Recursive count: " . sizeof($cars,1);
?>
$cars=array
(
"Volvo"=>array
(
"XC60",
"XC90"
),
"BMW"=>array
(
"X3",
"X5"
),
"Toyota"=>array
(
"Highlander"
)
);
echo "Normal count: " . sizeof($cars)."<br>";
echo "Recursive count: " . sizeof($cars,1);
?>
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
Compilers
Alfred V. Aho、Monica S. Lam、Ravi Sethi、Jeffrey D. Ullman / Addison Wesley / 2006-9-10 / USD 186.80
This book provides the foundation for understanding the theory and pracitce of compilers. Revised and updated, it reflects the current state of compilation. Every chapter has been completely revised ......一起来看看 《Compilers》 这本书的介绍吧!