$fruits = array("banana", "apple", "orange");
echo count($fruits);
You can get the length of an array in PHP by using count function. In the code snippet, we are counting $fruits variable values.
<?php
$subject = [
"name" => "Math",
"code" => "MT01",
"enrolls" => "20"
];
echo sizeof($subject);
// -> 3
?>
<?php
$subject=array(
"name" => "Math",
"students" => ["John", "Rick", "Diana"],
"classes" => [10, 12]
);
echo sizeof($subject, 1);
?>
0 Comments