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.
Challenge: Value or array - PHP Tutorial
From the course: Functional Programming with PHP
Challenge: Value or array
(electronic techno music) - [Instructor] Okay, let's move on to the third functional programming challenge. This challenge is called value or array and it goes like this. As you get deeper into functional programming, you may start to find that you're using array_map a lot. You've created a lot of nice functions, like double here, that work perfectly when you call them on a single value. But you find that you're working with a lot of arrays where you want to apply these functions to all the elements in the array. Normally if we want to apply a function to all the elements in an array, we need to use array_map. And there's nothing wrong with doing this, per se. But you might find that you're using array_map with a given function as often, or even more often, then you're using the function itself. Now you might remember back from a previous video about higher-order functions that we used first-class functions to wrap…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.