Answers for "how get count in php"

PHP
2

get count sql query in php

$result=mysql_query("SELECT count(*) as total from Students");
$data=mysql_fetch_assoc($result);
echo $data['total'];
Posted by: Guest on February-18-2021
1

count an array in php

<?php
 $vegetables = ["Cabbage", "Carrot", "Lettuce"];
 $arrayLength = count($vegetables);
 echo $arrayLength; //returns 3
?>
Posted by: Guest on June-20-2021

Browse Popular Code Answers by Language