From the course: Functional Programming with PHP

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Property getter

Solution: Property getter - PHP Tutorial

From the course: Functional Programming with PHP

Start my 1-month free trial

Solution: Property getter

(upbeat music) - [Instructor] Okay, so let's take a look at the solution for coding our create property getter function. Now this is a pretty short solution and it's really similar to some of the examples we saw in our partial applications section. So so far, our create property getter function is just a function that takes a key and a default value. So all we need to do is get this last array argument and past that to get property. So what we're going to do is return a function that takes array as an argument and finally just calls get property with the three arguments that we've accumulated. Key, default, and array. And that's it, the solution is as simple as that. If we run our code now, we see that we get the expected results from our person arrays up here.

Contents