I was wondering how can I check if an array is empty or not in a function
Here is part of my code.
if (!mysqli_query($dbc, $sql)) {
trigger_error(mysqli_error($dbc));
return;
} else {
$t = array();
while($row = mysqli_fetch_array($result)) {
$t[] = $row[0];
}
}
if($tr > 0){
$ts = array_sum($t);
}
$t[] = $row[0]is going to give the same value to every element in the$tarray. You need to put a counter in there.if (empty($array))and it doesn't matter inside of function or not