I have a function that counts the number of variables equal to one other, I used the technique in php for each, with $i = 1
and whenever they find $i++
.
My problem is that I would display the results, but now, if I have four results, it displays 1 2 3 4
.
How do you display only the total result?
PHP code :
if(!empty($myvar)) {
$i = 1;
foreach ($identity as $ent) {
if(($ent->name) === ($myvar->name)) {
echo $i;
$i++;
}
}
}