int count ( mixed $arr [, int $mode = COUNT_NORMAL ] )
引數說明:<?php $info = array( "C語言中文網", "http://c.biancheng.net/", "7 years old", array("C", "C++", "Java", "PHP", "Python") ); echo count($info) . "<br />"; //結果為4 echo count($info, 1); //結果為9 ?>執行結果:
array("C", "C++", "Java", "PHP", "Python")
作為一個整體會被統計一次,它裡面的元素又會被統計一次,所以最終結果為 9。<?php $url = "http://c.biancheng.net/php/"; $age = 8; echo count($url) . "<br />"; //結果為1 echo count($age); //結果為1 ?>執行結果: