Challenge 1: Recursive Count Function

Test your knowledge by writing a recursive version of PHP’s count function.

Problem statement

The count function in PHP counts all elements in an array or in a countable object. Write a recursive version of PHP’s count function named count_r that computes the size of an array.

Sample input

$array = ['a','b','c','d','e']

Expected output

5

Get hands-on with 1400+ tech skills courses.