I have array with stdClasses:
$a = new \stdClass();
$a->name = "aaa";
$a->type = "1";
$b = new \stdClass();
$b->name = "bbb";
$b->type = "2";
$c = new \stdClass();
$c->name = "ccc";
$c->type = "1";
$array = array($a, $b, $c);
$count = 0;
foreach ($array as $arr) {
if ($arr->type == 1) {
$count++;
}
}
Is better way to count types with value 1 than foreach? I would like counting many values so foreach is uncomfortable.
Maybe array_search or array_map?