function arr_count($arr)
{
    while (list(, $element) = @each($arr)) {
        if (is_array($element)) {
            $hasil += arr_count($element);
        } else {
            $single = true;
            continue;
        }
    }
    if ($single) {
        $hasil += count($arr);
    }
    return $hasil;
}
Beispiel #2
0
 public function testCount()
 {
     $input = [1, 2, 3];
     $this->assertEquals(3, arr_count($input));
 }