你可以使用PHP的 count()
函数来获取数组中键值的数量。例如:
$array = array("key1" => "value1", "key2" => "value2", "key3" => "value3");
$count = count($array);
echo $count; // 输出 3
在上面的例子中,我们定义了一个包含三个键值对的数组。然后使用 count()
函数获取数组中键值的数量,并将结果存储在 $count
变量中。最后,我们输出 $count
变量的值,结果为 3。