count() 공개 정적인 메소드

Example: $array = array(1, 2, 3); $count = Arrays::count($array, function ($element) { return $element < 3; }); Result: 2
public static count ( array $elements, callable $predicate ) : integer
$elements array
$predicate callable
리턴 integer
예제 #1
0
 /**
  * @test
  */
 public function shouldCountElements()
 {
     //given
     $array = array(1, 2, 3);
     //when
     $count = Arrays::count($array, function ($element) {
         return $element < 3;
     });
     //then
     $this->assertEquals(2, $count);
 }